How to create helper?


(megas) #1

I want to create eq helper. It already exists in ember-truth-helpers addon, but I need only eq so I decided create it by myself in my plugin.
I’ve created file assets/javascripts/discourse/helpers/eq.js.es6 with such content:

import { registerHelper } from 'discourse/lib/helpers';

registerHelper('eq', function(params) {
  return params[0] === params[1];
});

and use it in template in this way:

{{#if (eq param1 param2)}} <h1>hello</h1> {{/if}}

But eq is not defined.

What is the right way to create helper?