Ember CLI - How to use a util function in a template helper function?

What am I doing wrong here?

  • I define a util function isXDefactoEqualY.
  • I use this util function to define a template helper isXEqualY.
  • When using this template helper in a specific template, then this template is NOT rendered.
  • I see no compilation errors.
  • I see no errors in console.


import Ember from 'ember';

export default function ([model, list]) {
    ... code
    return true;


import Ember from 'ember';
import isXDefactoEqualY from '../utils/is-x-defacto-equal-y';

export function isXEqualY([model, list]) {
    return isXDefactoEqualY (model, list);

export default Ember.Helper.helper(isXEqualY);


<div>isXEqualY: {{isXEqualY myModel myList}}</div>

Helper names are dasherized in your template. Should be {{is-x-equal-y}}

Dasherizing (kebab-case) does not make a difference - I tried both :slight_smile: I have other not-based-on-a-util-function template helpers up running. For those helpers both {{kebab-case …} and {{camelCase …}} works fine.

isXDefactoEqualY is called with individual arguments instead of an array, resulting in:

Uncaught TypeError: Invalid attempt to destructure non-iterable instanceon line 3 ofapp/utils/is-x-defacto-equal-y.js`

I would change that function definition to:

export default function (model, list) { ... }

I also think the camelCase helper call is an issue, but maybe that’s environment-specific. Take a look at this twiddle to see what I’m talking about.

1 Like

@maffews, you are so spot-on!

Ember passes an array of arguments to a helper function!

The problem is, that I forgot to remove the array notation from the parameter list, when I copied from the original helper code.

My code now works perfect! Thank you @maffews! Case closed :slight_smile:

@maffews, I saw your twiddle. Yes, to avoid problems with different environments, it is probably best always to use kebab-case notation. Thank you!