github.com/armen/terraform@v0.5.2-0.20150529052519-caa8117a08f1/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);