Trouble adding Ember helper

(Steven Slade) #1

Continuing the discussion from How to add an Ember js helper?:

I am trying to add an Ember helper but having no luck. I get this error:

Uncaught Error: Assertion Failed: A helper named 'color-shade' could not be found

Below is my helper, color-shade.js

import Ember from 'ember';

export function colorShade(params) {
  //just placeholder code for now
  return params[0] === params[1];

export default Ember.Helper.helper(colorShade);

(Robin Ward) #2

Where did you put the helper? The location of the file matters.

(Steven Slade) #3

I am defining the helper in:


I am using the helper for a plugin outlet:


(Robin Ward) #4

Try the extension .js.es6 – otherwise it’s not autoloaded.

(Steven Slade) #5

Nice, good news is that A helper named 'color-shade' could not be found is no longer occurring.

Bad news is that I am now getting the error: Uncaught TypeError: Cannot read property 'helper' of undefined in regards to:

export default Ember.Helper.helper(colorShade);

Do I need to import Ember.Helper?

(Robin Ward) #6

I think that’s the newer ember api. We’re on an older version. I’d suggest just looking at how the discourse helpers are defined and copying that.

(Steven Slade) #7

:ok_hand: Bingo! Defining my helper the following way did the trick:

import registerUnbound from 'discourse/helpers/register-unbound';

registerUnbound('color-shade', function(params) {