Hey all-
I’ve extracted a bunch of code from our application that adds a new helper for Ember.Handlebars called registerTextHelper
. This helper eases development of textual transforms. Currently, I’m using it for our {{t}}
, {{l}}
, and {{simpleFormat}}
helpers. I think the current implementation of {{loc}}
lacks the ability to dynamically inject strings, and this would satisfy that use case with out of the box with a single line of code:
Ember.Handlebars.registerTextHelper('loc', Ember.String.loc, /`(.*?)`/g);
The {{loc}}
helper could now have dynamically interpolated strings on the view. I think this can be abused, but in this context, I believe it is within scope and the use case of:
{{#each App.currencies}}
{{loc "currency.`this`"}}
{{/each}}
Is hard not to see like a “win” in my mind.
In addition to {{loc}}
, I’ve posted gists for integration with I18n-js via the {{t}}
and {{l}}
helpers. In the near future, I’ll add our Rails-y {{simpleFormat}}
helper, which globs together Rails’ simple_format
and auto_link
helpers.
For the code, visit https://github.com/paddle8/ember-text-helper