Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

Revert "Describe dashes in helper names" #352

Merged
merged 1 commit into from
Jun 12, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions source/templates/writing-helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ Sometimes, you may use the same HTML in your application multiple times. In thos

For example, imagine you are frequently wrapping certain values in a `<span>` tag with a custom class. You can register a helper from your JavaScript like this:

```app/helpers/highlight-text.js
import Ember from 'ember';

```app/helpers/highlight.js
export default Ember.Handlebars.makeBoundHelper( function(value, options) {
var escaped = Ember.Handlebars.Utils.escapeExpression(value);
return new Ember.Handlebars.SafeString('<span class="highlight">' + escaped + '</span>');
Expand All @@ -18,7 +16,7 @@ user data!
Anywhere in your Handlebars templates, you can now invoke this helper:

```handlebars
{{highlight-text name}}
{{highlight name}}
```

and it will output the following:
Expand All @@ -31,23 +29,6 @@ If the `name` property on the current context changes, Ember.js will
automatically execute the helper again and update the DOM with the new
value.

Notice in the previous example that the helper name contains a dash. Helper names with dashes will get automatically loaded by Ember. It helps disambiguate properties from helpers, and helps mitigate the performance hit of helper resolution for all bindings. If you want to use a non-hyphenated name for your helper, such as `highlight`, you must explicity load the helper.

```app/helpers/highlight.js
export default function(value, options) {
var escaped = Ember.Handlebars.Utils.escapeExpression(value);
return new Ember.Handlebars.SafeString('<span class="highlight">' + escaped + '</span>');
};
```

```app/app.js
import Ember from "ember";
import highlightHelper from './helpers/highlight';

Ember.Handlebars.registerBoundHelper('highlight', highlightHelper);
```


### Dependencies

Imagine you want to render the full name of a `Person`. In this
Expand Down