Created
August 18, 2015 22:40
-
-
Save igorescobar/39f2f55af1e09dd51ac3 to your computer and use it in GitHub Desktop.
Registering global mustache helpers
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
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