Created
September 9, 2011 10:49
-
-
Save kates/1205935 to your computer and use it in GitHub Desktop.
faster resig micro template
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
(function(window){ | |
window.tmpl = function(str, c) { | |
var c = c || "it"; | |
return new Function(c, | |
"var p=[];p.push('" + | |
str.replace(/[\r\t\n]/g, " ") | |
.replace(/'(?=[^<]*%>)/g,"\t") | |
.replace(/'/g, "\\'") | |
.replace(/\t/g, "'") | |
.replace(/<%=(.+?)%>/g, "',$1,'") | |
.replace(/<%/g, "');") | |
.replace(/%>/g, "p.push('") + | |
"');return p.join('');" | |
); | |
}; | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment