Skip to content

Instantly share code, notes, and snippets.

@jedschneider
Forked from plukevdh/lazy_mustachio.coffee
Last active December 16, 2015 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedschneider/5460217 to your computer and use it in GitHub Desktop.
Save jedschneider/5460217 to your computer and use it in GitHub Desktop.
class Mustachio extends Backbone.View
render: (template_id, context) ->
@templates[template_id].call @, context
@prepare = ->
templates = {}
raw_templates = $('script[type="text/x-handlebars-template"]')
raw_templates.each (i, template) ->
$template = $(template)
templates[$template.attr('id')] = Handlebars.compile($template.html())
@::templates = templates
window.Mustachio = Mustachio
$ ->
Mustachio.prepare()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment