Buy Handlebars swag on DevSwag!
Get the HTML result of evaluating a Handlebars template by executing the template with a context.
var context = {title: "My New Post", body: "This is my first post!"}
var html    = template(context);
results in
<div class="entry">
  <h1>My New Post</h1>
  <div class="body">
    This is my first post!
  </div>
</div>

Options

The template function can be passed an options object as the second parameter which allows for customization:
  • data Pass in an object to define custom @variable private variables.
  • helpers Pass in to provide custom helpers in addition to the globally defined helpers.
    Values defined in this object will replace any values defined in the global object for the duration of the template execution.
  • allowCallsToHelperMissing (since 4.3.0, insecure): If set to true, calls like {{helperMissing}} and {{blockHelperMissing}} will be allowed. Please not that this allows template authors to fabricate templates for Remote Code Execution on the environment running Handlebars (see https://github.com/wycats/handlebars.js/issues/1558)
Found a documentation issue? Tell us!
Fork me on GitHub