Created
July 22, 2009 00:24
-
-
Save anutron/151722 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hash.implement({ | |
substitute: function(template, regexp){ | |
return template.replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){ | |
if (match.charAt(0) == '\\') return match.slice(1); | |
if (this.get(name)) return this.get(name); | |
if (name.contains(".")) { | |
var found = this.getFromPath(name); | |
return found ? found : ""; | |
} | |
}.bind(this)); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment