Skip to content

Commit

Permalink
Cleaning up {{loc}}
Browse files Browse the repository at this point in the history
  * Simplify helper by just re-exporting StringUtils.loc
  * Removes inline script style example
  * Adds example Ember.String setup and resulting output
  • Loading branch information
trek committed Sep 28, 2014
1 parent 728b326 commit b675d33
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions packages/ember-handlebars/lib/helpers/loc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,29 @@ import { loc } from "ember-runtime/system/string";
@submodule ember-handlebars
*/

// ES6TODO:
// Pretty sure this can be expressed as
// var locHelper EmberStringUtils.loc ?

/**
Calls [Ember.String.loc](/api/classes/Ember.String.html#method_loc) with the
provided string.
This is a convenient way to localize text. For example:
This is a convenient way to localize text within a template:
```html
<script type="text/x-handlebars" data-template-name="home">
{{loc "welcome"}}
</script>
```javascript
Ember.STRINGS = {
'_welcome_': 'Bonjour'
};
```
```handlebars
<div class='message'>
{{loc '_welcome_'}}
</div>
```
Take note that `"welcome"` is a string and not an object
reference.
```html
<div class='message'>
Bonjour
</div>
```
See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to
set up localized string references.
Expand All @@ -32,6 +37,4 @@ import { loc } from "ember-runtime/system/string";
@param {String} str The string to format
@see {Ember.String#loc}
*/
export default function locHelper(str) {
return loc(str);
}
export default loc;

0 comments on commit b675d33

Please sign in to comment.