helper (helper) publicstatic
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
Please login to continue.