Skip to content

Instantly share code, notes, and snippets.

@Dammmien
Last active April 27, 2023 22:41
Show Gist options
  • Save Dammmien/5f0bff8643cb931da7e9495f782aad0a to your computer and use it in GitHub Desktop.
Save Dammmien/5f0bff8643cb931da7e9495f782aad0a to your computer and use it in GitHub Desktop.
Mustache cheatsheet

Basic tag

  Hello {{name}} !!

Comments

  {{! This is a comment, and it won't be rendered }}

Loop through a list of items

{{#list}}
  {{property}} // item.property
  or
  {{.}} // item
{{/list}}

Show a block if a variable is falsy, an empty list or a function returning a falsy value

{{^variable}}
  variable is a falsy or an empty list
{{/variable}}

Show a block if a variable is truthy or a function returning a truthy value

{{#variable}}
  variable is truthy
{{/variable}}

Import / include another template

{{> header}}

Render unescaped HTML

{{{<span>unescaped</span>}}} or {{&<span>unescaped</span>}}
@xcesaralejandro
Copy link

useful summary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment