Skip to content

Instantly share code, notes, and snippets.

@FoxxMD
Forked from Dammmien/mustache.md
Created June 4, 2021 17:31
Show Gist options
  • Save FoxxMD/d365707cf99fdb526a504b8b833a5b78 to your computer and use it in GitHub Desktop.
Save FoxxMD/d365707cf99fdb526a504b8b833a5b78 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>}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment