Skip to content

Instantly share code, notes, and snippets.

@ndemengel
Last active November 20, 2016 21:04
Show Gist options
  • Save ndemengel/adf4018f2676131a00680431f605aacd to your computer and use it in GitHub Desktop.
Save ndemengel/adf4018f2676131a00680431f605aacd to your computer and use it in GitHub Desktop.
Handlebars example
<p>Handlebars escapes all texts by default. This is safe: {{htmlEscapedVariable}},
this is not {{{nonEscapedVariable}}}.</p>
<ul>
{{#each items}}
{{!-- Within this #each block, "name", "link" and "url" are properties of the current item. --}}
{{!-- Also: @first, @last and @index are automatically provided for convenience. --}}
{{#if @first}}
<li>First item: {{name}}</li>
{{else if link}}
<li>Not first item: <a href="{{url}}">{{name}}</a></li>
{{else}}
<li>Not first item, not a link: {{name}}</li>
{{/if}}
{{else}}
<li>Not items to show.</li>
{{/each}}
</ul>
{{#unless someCondition}}
{{!-- formatDate is a custom helper, taking both regular and named arguments: --}}
{{formatDate someDate year=false month="long"}}
{{/unless}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment