Skip to content

Instantly share code, notes, and snippets.

@skw
Forked from berzniz/gist:2900905
Last active December 17, 2015 14:09
Show Gist options
  • Save skw/5622844 to your computer and use it in GitHub Desktop.
Save skw/5622844 to your computer and use it in GitHub Desktop.
CS Fork get handle bar template function example
# get template on the fly
Handlebars.getTemplate = (name)->
if Handlebars.templates is undefined or Handlebars.templates[name] is undefined
$.ajax(
url: "/templates/" + name
success: (data) ->
Handlebars.templates = {} if Handlebars.templates is undefined
Handlebars.templates[name] = Handlebars.compile(data)
error: (xhr, options, err) ->
console.log xhr.status
console.log 'error: ' + err
async: false
)
Handlebars.templates[name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment