Created
September 3, 2014 02:56
-
-
Save ijse/5d5facc7b1498956e33d to your computer and use it in GitHub Desktop.
tiny template engine
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 helper | |
function tpl(t, d) { | |
var s = t; | |
if (!d) return s; | |
for (k in d) { | |
s = s.replace(new RegExp('\\${' + k + '}', 'g'), d[k]); | |
} | |
return s; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment