github.com/hobbeswalsh/terraform@v0.3.7-0.20150619183303-ad17cf55a0fa/website/source/assets/javascripts/lib/String.substitute.js (about) 1 (function(String){ 2 3 if (String.prototype.substitute) { 4 return; 5 } 6 7 String.prototype.substitute = function(object, regexp){ 8 return String(this).replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){ 9 if (match.charAt(0) == '\\') return match.slice(1); 10 return (object[name] !== null) ? object[name] : ''; 11 }); 12 }; 13 14 })(String);