A collection of js functions that are less than or equal to 140 characters.
Created
November 3, 2011 01:42
-
-
Save nijikokun/1335539 to your computer and use it in GitHub Desktop.
Less Than 140 Chars - JS
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
/* t in coffeescript */ | |
t = (s,o,p = '{',e = '}') -> | |
for own i of o | |
s = s.replace(new RegExp(p+i+e,'g'),o[i]) | |
return s |
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
// t | |
// Author: Nijikokun | |
// Description: Templating | |
// Usage: | |
// | |
// console.log(t('Hello {n} with {n} n', { n: '1'})) | |
// | |
function t (a,b,c,d){c=c||'{';d=d||'}';for(var e in b)e in b&&(a=a.replace(RegExp(c+e+d,'g'), b[e]));return a;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's an interesting concept.