-
-
Save nowri/5663390 to your computer and use it in GitHub Desktop.
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
// Template | |
// (c) 2011 Jason Byrne, MileSplit | |
// May be freely distributed under the MIT license, with attribution. | |
// | |
// ** Usage ** | |
// | |
// HTML: | |
// <script type="text/html" id="tmplArticle"><h1>${Title}</h1></script> | |
// | |
// JavaScript: | |
// $('#tmplArticle').tmpl(data).appendTo($item); | |
// | |
(function($){ | |
$.fn.tmpl = function(d) { | |
var s = $(this[0]).html().trim(); | |
if (d) { | |
for (k in d) { | |
s = s.replace(new RegExp('\\${' + k + '}', 'g'), d[k]); | |
} | |
} | |
return $(s); | |
}; | |
})(Zepto); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment