Skip to content

Instantly share code, notes, and snippets.

@thurloat
Created April 10, 2013 15:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thurloat/5355714 to your computer and use it in GitHub Desktop.
Save thurloat/5355714 to your computer and use it in GitHub Desktop.
django / jinja style underscore templates
/**
* 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