In an ember.js application, I have created a custom helper which is used for text localization. Specifically, it is passing the value given to the helper through Jed, a gettext-style text translation library like so:
Ember.Handlebars.helper('_', function(value, options) {
return Lang.gettext(value);
});
And in my templates:
{{_ "Translate Me"}}
The problem is that ember renders this as a bound helper, i.e. the rendered text value is surrounded in <script id="metamorph-*">
tags, but as the values will never change, I want them to be unbound in order to avoid the extra overhead and markup.
In the API docs I did see the workaround solution for this:
The {{unbound}} helper can be used with bound helper invocations to render them in their unbound form, e.g.
However I would much prefer a way to just globally define my helper as an unbound helper, so that I don't have to type {{unbound _ "Foo"}}
for every localized string. Not to mention that doing this would cause the strings to not be parseable by the library I use (xgettext-template) to extract all the localized strings from the source code.
registerHelper
works fine for the base case, but what aboutngettext
? I want to do{{ngettext 'person' 'people' count}}
, wherecount
is bound. – user663031