Last active
February 3, 2018 05:56
-
-
Save jonschlinkert/b2691da836a4c1158f4e to your computer and use it in GitHub Desktop.
A helper that adds variables from the options hash to the `@` namespace (like `@root`).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handlebars.registerHelper('foo', function (name, context, options) { | |
var fn = Handlebars.compile(Handlebars.partials[name]); | |
var frame = Handlebars.createFrame(context.data); | |
for (var prop in options.hash) { | |
frame[prop] = options.hash[prop]; | |
} | |
var template = fn(context, {data: frame}); | |
return new Handlebars.SafeString(template); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment