Created
August 8, 2009 01:42
-
-
Save whalesalad/164273 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Screwing around... | |
| String.prototype.inter = function(r) { | |
| return this.replace(/\{([^}]+)\}/g, function() { | |
| return r[arguments[1]]; | |
| }); | |
| } | |
| $(document).ready(function() { | |
| var string = 'There are {num_kids} kids in the {room_name}.'; | |
| alert(string.inter({ | |
| num_kids: 42, | |
| room_name: 'living room' | |
| })); | |
| }); | |
| // Will alert "There are 42 kids in the living room."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment