Skip to content

Instantly share code, notes, and snippets.

@kevinmarx
Last active December 21, 2015 07:19
Show Gist options
  • Save kevinmarx/6270249 to your computer and use it in GitHub Desktop.
Save kevinmarx/6270249 to your computer and use it in GitHub Desktop.
topic helper for handlebars templates.
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