-
-
Save skw/5622844 to your computer and use it in GitHub Desktop.
CS Fork get handle bar template function example
This file contains 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
# 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