terraform/website/source/javascripts/lib/String.substitute.js

15 lines
336 B
JavaScript
Raw Normal View History

2014-07-24 04:50:28 +02:00
(function(String){
if (String.prototype.substitute) {
return;
}
String.prototype.substitute = function(object, regexp){
return String(this).replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){
if (match.charAt(0) == '\\') return match.slice(1);
return (object[name] !== null) ? object[name] : '';
});
};
})(String);