silverbulletmd / silverbullet

The knowledge tinkerer's notebook
https://silverbullet.md
MIT License
2.35k stars 169 forks source link

Feature request: Nested each #773

Closed Sindarin27 closed 7 months ago

Sindarin27 commented 7 months ago

It would be nice to allow an each-loop within another each-loop within the template language. As far as I can tell, this currently gives a parsing error. As an example, the following template function could give a bullet list of the inherited tags of each page.

{{#each {page}}}
{{name}}
  {{#each @tag in {{itags}} }}
- {{@tag}}
  {{/each}}
{{/each}}

Current output is as follows:

Error: Parse error in: {{#each {page}}}
{{name}}
  {{#each @tag in {{itags}} }}
- {{@tag}}
  {{/each}}
{{/each}}

Desired output would be e.g.:

index
- page
SETTINGS
- page
Lord Of The Rings
- page
- book
Sindarin27 commented 7 months ago

Sorry, it appears this feature already exists and the error message was correct. The syntax should simply have been as follows, and I simply did not try enough things.

{{#each {page}}}
{{name}}
  {{#each @tag in itags }}
- {{@tag}}
  {{/each}}
{{/each}}