Created
April 26, 2013 03:55
-
-
Save JiLiZART/5464953 to your computer and use it in GitHub Desktop.
doT.js jQuery wrapper function by Artem Sapegin
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
$.fn.tmpl = function(tmplId, data) { | |
var tmpl = doT.template($('#tmpl_' + tmplId).text()); | |
if (!$.isArray(data)) data = [data]; | |
return this.each(function() { | |
var html = ''; | |
for (var itemIdx = 0; itemIdx < data.length; itemIdx++) { | |
html += tmpl(data[itemIdx]); | |
} | |
$(this).html(html); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment