Skip to content

Instantly share code, notes, and snippets.

@jonathan-beebe
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathan-beebe/9916897 to your computer and use it in GitHub Desktop.
Save jonathan-beebe/9916897 to your computer and use it in GitHub Desktop.
Looping through data using Assemble.io + Handlebars
---
headings: [1, 2, 3, 4, 5, 6]
---
<div data-section="headings">
{{#each headings}}
{{#withHash num=this text="Heading"}}
<h{{num}}>{{text}} {{num}}</h{{num}}>
{{/withHash}}
{{/each}}
</div>
<!-- or -->
<div data-section="headings">
{{#withHash text="Heading" items="123456"}}
{{#forEach items}}
<h{{.}}>{{../text}} {{.}}</h{{.}}>
{{/forEach}}
{{/withHash}}
</div>
<!-- renders -->
<div data-section="headings">
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment