Skip to content

Instantly share code, notes, and snippets.

@fitnr
Last active March 24, 2020 18:43
Show Gist options
  • Save fitnr/8961717 to your computer and use it in GitHub Desktop.
Save fitnr/8961717 to your computer and use it in GitHub Desktop.
Example of the filter helper in handlebars
---
animal: cat
mylist:
- dog
- bear
- cat
myprop: species
zoo:
- species: dog
name: odie
- species: cat
name: felix
- species: lion
name: leo
---
{{#filter mylist animal}}
look, there's a {{this}}
{{else}}
no cats found
{{/filter}}
{{!-- outputs "look there's a cat" --}}
{{#filter zoo animal property=myprop}}
hi {{ name }}
{{else}}
no cats found
{{/filter}}
{{!-- "hi felix" --}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment