steveosoule
9/5/2014 - 5:27 PM

Supplant: Simple templates with Vanilla JS

Supplant: Simple templates with Vanilla JS

// FROM: http://www.qwiple.com/posts/14106/simple-templates-with-vanilla-js
if (!String.prototype.supplant) {
	String.prototype.supplant = function(o) {
		return this.replace(/{([^{}]*)}/g, function(a, b) {
			var r = o[b];
			return typeof r === 'string' ? r : a;
		});
	};
}