Helper.helper()

helper (helper) publicstatic

Defined in packages/ember-htmlbars/lib/helper.js:109
Available since 1.13.0

In many cases, the ceremony of a full Ember.Helper class is not required. The helper method creates pure-function helpers without instances. For example:

// app/helpers/format-currency.js
export function formatCurrency([cents], hash) {
  let currency = hash.currency;
  return `${currency}${cents * 0.01}`;
});

export default Ember.Helper.helper(formatCurrency);

// tests/myhelper.js
import { formatCurrency } from ..../helpers/myhelper
// add some tests

This form is more efficient at run time and results in smaller compiled js. It is also easier to test by using the following structure and importing the formatCurrency function into a test.

Parameters:

helper Function
The helper function
doc_EmberJs
2016-11-30 16:52:12
Comments
Leave a Comment

Please login to continue.