Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mustache.to_javascript("Hello {{planet}}")
function (obj) {
var out, l1, stack, fetch, escape, isFunction;
out = [];
stack = [];
stack.push(obj);
fetch = function fetch(key) {
var i, v;
for (i = stack.length - 1; i >= 0; i -= 1) {
v = stack[i][key];
if (v) {
return v;
}
}
};
escape = function escape(value) {
return ('' + value)
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
};
isFunction = function isFunction(obj) {
return !!(obj && obj.constructor && obj.call && obj.apply);
};
out.push("Hello ");
l1 = fetch("planet");
if (isFunction(l1)) {
l1 = l1();
}
out.push(escape(l1));
return out.join("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.