Menu

gitpiper

Handlebars.js Cheat Sheet in March 2024

Last Updated: 22 March 2024

README.md

{% raw %}

Helpers

Handlebars.registerHelper('link_to', function() {
  return "<a href='" + this.url + "'>" + this.body + "</a>";
})
var context = { posts: [{url: "/hello-world", body: "Hello World!"}] }
var source = "<ul>{{#posts}}<li>{{{link_to}}}</li>{{/posts}}</ul>"
var template = Handlebars.compile(source)
template(context)

Would render:

<ul>
  <li><a href='/hello-world'>Hello World!</a></li>
</ul>

{% endraw %}


338+ more cheat sheets for you in March 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️