Last active
December 21, 2015 07:19
-
-
Save kevinmarx/6270249 to your computer and use it in GitHub Desktop.
topic helper for handlebars templates.
This file contains 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
var Handlebars = require('handlebars') | |
var _ = require('underscore') | |
/* | |
* Adds support for passing items into a context as variables | |
* | |
* USAGE: {{#topic this foo=bar baz=qux}} | |
* USAGE: {{#topic foo=bar}} no need for a context, this will create a new context object | |
*/ | |
Handlebars.registerHelper('topic', function(context, options) { | |
context = _.extend({}, context, options.hash) | |
return context | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment