Fixes #542: render each and render all

This commit is contained in:
Zef Hemel
2023-10-30 14:15:12 +01:00
parent 1d8e7d5c35
commit 8f4d6e5d23
13 changed files with 74 additions and 17 deletions
+7
View File
@@ -1,6 +1,13 @@
An attempt at documenting the changes/new features introduced in each
release.
---
## 0.5.4
* Many styling fixes and improvements to [[Live Queries]] and [[Live Templates]]
* Added a “source” button to [[Live Queries]] and [[Live Templates]] for better debugging (showing you the markdown code rendered by the template so you can more easily detect issues)
* [[Live Queries]]:
* Support for `render all` where the entire result set is passed to a single template allowing you to e.g. dynamically build up tables, see [[Live Queries@render]] for an example.
---
## 0.5.3
* Changes to [[Objects]]:
+14 -3
View File
@@ -55,14 +55,25 @@ person
where page = "{{@page.name}}"
select name, age, age + 1 as nextYear
```
### `render [[template]]`
By default results are rendered as a table, to instead render each result item using [[Templates|a template]], use the `render` clause:
### `render each [[template]]` and `render all [[template]]`
$render
By default results are rendered as a table, to instead render results using [[Templates|a template]], use the `render` clause, which comes in two shapes `render each` where the template is instantiated for _each_ result (the `each` keyword is optional):
```query
person
where page = "{{@page.name}}"
render [[template/person]]
render each [[template/person]]
```
And `render all` where the entire result set is passed to the template as a list so the template can do its own iteration using `#each`, which you could then use to e.g. build a table (using this [[template/people]] template for instance):
```query
person
where page = "{{@page.name}}"
render all [[template/people]]
```
## Expressions
$expression
+5
View File
@@ -0,0 +1,5 @@
| Name | Age |
|----------|----------|
{{#each .}}
| **{{name}}** | {{age}} |
{{/each}}