Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Registering global mustache helpers
function i18nLambda (text, render) {
text = dict[text] || text
return render(text)
}
var Context = mustache.Context
Context.prototype._lookup = Context.prototype.lookup
Context.prototype.lookup = function i18nLookup (name) {
return (name === 'i18n' ? i18nLambda : this._lookup(name)
}
// {{#i18n}}Hello.{{/i18n}} {{#i18n}}My name is {{ name }}.{{/i18n}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment