Skip to content

Commit cdc9d0b

Browse files
authored
feat: create docs for table-row-object (windmill-labs#608)
1 parent 2530b66 commit cdc9d0b

File tree

1 file changed

+19
-17
lines changed
  • docs/core_concepts/19_rich_display_rendering

1 file changed

+19
-17
lines changed

docs/core_concepts/19_rich_display_rendering/index.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,30 @@ This feature is useful if you want to display an image, a GIF, a file, or specif
88

99
If the result is an object/dict with a single key (except for `approval`, which needs 3), you can leverage the following rich results:
1010

11-
| Type | Description | Example |
12-
| ---------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
13-
| json | Render the value as a JSON | `return { "json": { "a": 1 } }` |
14-
| table-col | Render the value as a column in a table | `return { "table-col": { "foo": [42, 8], "bar": [38, 12] }}` |
15-
| table-row | Render the value as a row in a table | `return { "table-row": [ "foo", "bar" ]}` |
16-
| html | Render the value as HTML | `return { "html": "<div>...</div>" }` |
17-
| png | Render the value as a PNG image | `return { "png": { "content": encode(image) } }` or `return { "png": encode(image) }` |
18-
| file | Render an option to download the file | `return { "file": { "content": encode(file), "filename": "data.txt" } }` |
19-
| jpeg | Render the value as a JPEG image | `return { "jpeg": { "content": encode(image) } }` or `return { "jpeg": encode(image) }` |
20-
| gif | Render the value as a GIF image | `return { "gif": { "content": encode(image) } }` or `return { "gif": encode(image) }` |
21-
| error | Render the value as an error message | `return { "error": { "name": "418", "message": "I'm a teapot" }}` |
22-
| approval | Render an approval and buttons to Resume or Cancel the step | `return { "resume": "https://example.com", "cancel": "https://example.com", "approvalPage": "https://example.com" }` |
23-
| svg | Render the value as an SVG image | `return { "svg": "<svg>...</svg>" }` |
24-
| markdown | Render the value as Markdown | `return { "markdown": "## Hello World" }` or `return { "md": "## Hello World" }` |
25-
| render_all | Render all the results | `return { "render_all": [ { "json": { "a": 1 } }, { "table-col": { "foo": [42, 8], "bar": [38, 12] }} ] }` |
26-
| map | Render a map with a given location | `return { "map": { lat: 40, lon: 0, zoom: 3, markers: [{lat: 50.6, lon: 3.1, title: "Home", radius: 5, color: "yellow", strokeWidth: 3, strokeColor: "Black"}]}}` |
11+
| Type | Description | Example |
12+
| ---------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
13+
| json | Render the value as a JSON | `return { "json": { "a": 1 } }` |
14+
| table-col | Render the value as a column-wise table | `return { "table-col": { "foo": [42, 8], "bar": [38, 12] } }` |
15+
| table-row | Render the value as a row-wise table | `return { "table-row": [ [ "foo", "bar" ], [ 42, 38 ], [ 8, 12 ] ] }` |
16+
| table-row-object | Render the value as a row-wise table but where each row is an object (optionally the first row can be an array of strings to enforce column order) | `return { "table-row-object": [ { "foo": 42, "bar": 38 }, { "foo": 8, "bar": 12 } ] }` or `return { "table-row-object": [ ["foo", "bar" ], { "foo": 42, "bar": 38 }, { "foo": 8, "bar": 12 } ] } to enforce column order` |
17+
| html | Render the value as HTML | `return { "html": "<div>...</div>" }` |
18+
| png | Render the value as a PNG image | `return { "png": { "content": encode(image) } }` or `return { "png": encode(image) }` |
19+
| file | Render an option to download the file | `return { "file": { "content": encode(file), "filename": "data.txt" } }` |
20+
| jpeg | Render the value as a JPEG image | `return { "jpeg": { "content": encode(image) } }` or `return { "jpeg": encode(image) }` |
21+
| gif | Render the value as a GIF image | `return { "gif": { "content": encode(image) } }` or `return { "gif": encode(image) }` |
22+
| error | Render the value as an error message | `return { "error": { "name": "418", "message": "I'm a teapot" }}` |
23+
| approval | Render an approval and buttons to Resume or Cancel the step | `return { "resume": "https://example.com", "cancel": "https://example.com", "approvalPage": "https://example.com" }` |
24+
| svg | Render the value as an SVG image | `return { "svg": "<svg>...</svg>" }` |
25+
| markdown | Render the value as Markdown | `return { "markdown": "## Hello World" }` or `return { "md": "## Hello World" }` |
26+
| render_all | Render all the results | `return { "render_all": [ { "json": { "a": 1 } }, { "table-col": { "foo": [42, 8], "bar": [38, 12] }} ] }` |
27+
| map | Render a map with a given location | `return { "map": { lat: 40, lon: 0, zoom: 3, markers: [{lat: 50.6, lon: 3.1, title: "Home", radius: 5, color: "yellow", strokeWidth: 3, strokeColor: "Black"}]}}` |
28+
29+
**Note for tables**: If the result matches the table format (either `table-col`, `table-row`, or `table-row-object`), it will be displayed as a table even if the the data is not nested under the key `table-*`.
2730

2831
![Rich display HTML](./rich_display_html.png "Rich display HTML")
2932

3033
![Rich display map](./rich_display_map.png "Rich display map")
3134

32-
**Regarding the tables**: If the result is a list whose first element is also a list, it will display the result as a table. If the result is a dict/object where every value is an array, it will also be displayed as a table, with the key as the column name.
3335

3436
For example:
3537

0 commit comments

Comments
 (0)