Skip to content

Instantly share code, notes, and snippets.

@BriSeven
Last active December 19, 2015 22:29
Show Gist options
  • Save BriSeven/6027591 to your computer and use it in GitHub Desktop.
Save BriSeven/6027591 to your computer and use it in GitHub Desktop.
Hairlip: A very very tiny mustache-like thing.
// 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