Created
April 3, 2013 14:37
-
-
Save padakuro/5301766 to your computer and use it in GitHub Desktop.
simple backbone marionette handlebars renderer (coffee script)
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
| 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