Last active
December 19, 2015 22:29
-
-
Save BriSeven/6027591 to your computer and use it in GitHub Desktop.
Hairlip: A very very tiny mustache-like thing.
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
// Hairlip is | |
// a very tiny version of mustache that only does variable replacement | |
// and nothing else. | |
String.prototype.hairlip = function (o) { | |
"use strict"; | |
return this.replace(/\{\{([a-zA-Z0-9_\-]*)\}\}/g, function (a, b) { | |
/*jslint unparam:true*/ | |
return { | |
string: true, | |
number: true | |
}[typeof o[b]] ? o[b] : ""; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment