Skip to content

Instantly share code, notes, and snippets.

@Adrian2112
Created June 25, 2012 16:41
Show Gist options
  • Save Adrian2112/2989662 to your computer and use it in GitHub Desktop.
Save Adrian2112/2989662 to your computer and use it in GitHub Desktop.
Handlebars demo
jQuery ->
amigos = {
amigos: [
{nombre: "Adrian"}
{nombre: "Eduardo"}
{nombre: "Abraham"}
]
}
amigos_tmpl = Handlebars.compile( $("#amigos_tmpl").html() )
html = amigos_tmpl(amigos)
$("#amigos").html(html)
<body>
<div id="amigos">
</div>
</body>
<script id="amigos_tmpl" type="text/x-handlebars-template">
<ul>
{{#each amigos}}
<li>{{nombre}}</li>
{{/each}}
</ul>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment