Created
April 10, 2013 15:38
-
-
Save thurloat/5355714 to your computer and use it in GitHub Desktop.
django / jinja style underscore templates
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
/** | |
* Custom Underscore.js _.template settings to make it behave more like the | |
* django & jinja style templates that we're used to writing. | |
* | |
* {{ variable }} - prints into the template | |
* {% evaluation %} - inserts some JS to evaulate into the template. | |
* | |
* example: | |
* | |
* {% _.each(paragraphs, function(paragraph) { %} | |
* <p>{{ paragraph }}</p> | |
* {% }); %} | |
* | |
*/ | |
_.templateSettings = { | |
'interpolate':/\{\{(.+?)\}\}/g, | |
'evaluate':/\{%(.+?)%\}/g | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment