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
+11-12Lines changed: 11 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -1534,21 +1534,20 @@ SELECT
1534
1534
```
1535
1535
', NULL),
1536
1536
('shell', '
1537
-
### A page without a shell
1538
-
SQLPage provides the `shell-empty` component to create a page without a shell.
1539
-
In this case, the `<html>` and `<body>` tags are not generated, and the components are rendered directly in the page
1540
-
without any styling, navigation bar, footer, or dynamic content.
1541
-
Any component whose name starts with `shell` will be considered as a shell component,
1542
-
so you can also [create your own shell component](custom_components.sql#custom-shell).
1537
+
### Returning custom HTML, XML, plain text, or other formats
1543
1538
1544
-
This is particularly useful when creating a [RESTful API](https://en.wikipedia.org/wiki/REST) with SQLPage.
1545
-
Typically, the data returned to the client is not formatted in HTML but rather in JSON or XML.
1546
-
With the `shell-empty` component, you simply need to construct the formatted data and assign it to the contents property.
1539
+
Use `shell-empty` to opt out of SQLPage''s component system and return raw data directly.
1547
1540
1548
-
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.
1541
+
By default, SQLPage wraps all your content in a complete HTML page with navigation and styling.
1542
+
The `shell-empty` component tells SQLPage to skip this HTML wrapper and return only the raw content you specify.
1549
1543
1550
-
In the example below, SQLPage returns data formatted in XML.
1551
-
The correct [MIME](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types/Common_types) type should be `application/xml`.
1544
+
Use it to create endpoints that return things like
1545
+
- XML (for JSON, use the [json](?component=json) component)
1546
+
- plain text or markdown content (for instance for consumption by LLMs)
1547
+
- a custom data format you need
1548
+
1549
+
When using `shell-empty`, you should use the [http_header](component.sql?component=http%5Fheader) component first
1550
+
to set the correct [content type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) (like `application/json` or `application/xml`).
0 commit comments