github.com/erriapo/terraform@v0.6.12-0.20160203182612-0340ea72354f/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);