You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/official-site/sqlpage/migrations/01_documentation.sql
+28-12Lines changed: 28 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -1525,22 +1525,38 @@ SELECT
1525
1525
SQLPage provides the `shell-empty` component to create a page without a shell.
1526
1526
In this case, the `html` and `body` tags are not generated, and the components are rendered directly in the page
1527
1527
without any styling, navigation bar, footer, or dynamic content.
1528
-
This is useful when you want to generate a snippet of HTML that can be dynamically included in a larger page.
1529
-
1530
1528
Any component whose name starts with `shell` will be considered as a shell component,
1531
1529
so you can also [create your own shell component](custom_components.sql#custom-shell).
1532
1530
1531
+
This is particularly useful when creating a [RESTful API](https://en.wikipedia.org/wiki/REST) with SQLPage.
1532
+
Typically, the data returned to the client is not formatted in HTML but rather in JSON or XML.
1533
+
With the `shell-empty` component, you simply need to construct the formatted data and assign it to the contents property.
1534
+
1535
+
Remember to use the [http_header](component.sql?component=http%5Fheader) component beforehand to inform the client about the format of the data being sent.
1536
+
1537
+
In the example below, SQLPage returns data formatted in XML.
1538
+
The correct [MIME](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types/Common_types) type should be `application/xml`.
If you create a RESTful API with SQLPage and the data format transmitted to the client is not HTML,
1540
-
you can use an alias named `contents` to enhance the readability of your code.
1541
-
This approach is particularly useful for returning data formats such as JSON or XML.
1556
+
as you are stepping out of the safe SQLPage framework and into the wild world of HTML.
1542
1557
1543
-
Remember to use the [http_header](component.sql?component=http%5Fheader) component beforehand to inform the client about the format of the data being sent.
1544
-
For example, for XML, the correct [MIME](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types/Common_types) type should be `application/xml`.
1558
+
In this scenario, you can use the `html` property, which serves as an alias for the `contents` property.
1559
+
This property improves code readability by clearly indicating that you are generating HTML.
1560
+
Since SQLPage returns HTML by default, there is no need to specify the content type in the HTTP header.
0 commit comments