Skip to content

Instantly share code, notes, and snippets.

View weber's full-sized avatar

Sergey Kirichenko weber

View GitHub Profile
@il-b
il-b / gist:1901458
Created February 24, 2012 14:59
Include tag for underscore template
// based on http://emptysquare.net/blog/adding-an-include-tag-to-underscore-js-templates/
// include tag for underscore templates
// <% include template-id %>
var _underscore_template = _.template;
_.template = function(str, data) {
// match "<% include template-id %>"
return _underscore_template(
str.replace(
/<%\s*include\s*(.*?)\s*%>/g,
<!-- templates -->
<script id="summary" type="text/x-handlebars-template">
{{#users}}
{{>summaryItem}}
{{/users}}
</script>
<script id="summaryItem" class="partial" type="text/x-handlebars-template">
<li id="user_{{id}}" class="summary_item">
<p>{{name}}</p>