Last active
December 27, 2015 10:19
-
-
Save jtenner/7310311 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
Object.prototype.template = function(templateStr){ | |
var that = this; | |
return templateStr.replace(/\{\{([a-zA-Z\_0-9\.]*?)\}\}/g, function(match){ | |
match.slice(2,-2).split('.').forEach(function(item){ | |
that = that[item]; | |
}); | |
return that; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment