Skip to content

Instantly share code, notes, and snippets.

@padakuro
Created April 3, 2013 14:37
Show Gist options
  • Select an option

  • Save padakuro/5301766 to your computer and use it in GitHub Desktop.

Select an option

Save padakuro/5301766 to your computer and use it in GitHub Desktop.
simple backbone marionette handlebars renderer (coffee script)
do ->
templateCache = {}
Backbone.Marionette.Renderer.render = (template, data) ->
if templateCache[template]
tpl = templateCache[template]
else
source = $("script[data-template-name='#{template}']");
unless source.length > 0
throw "Template #{template} not defined!"
templateCache[template] = tpl = Handlebars.compile(source.html())
tpl(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment