vendredi 23 septembre 2016

How to create template helper

I want to create eq helper. It already exists in ember-truth-helpers addon, but I need only eq helper so I decided create it by myself in my plugin.

I've created file assets/javascripts/discourse/helpers/eq.js.es6 in my plugin 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:

 <h1>hello</h1> 

But eq is not defined.

What is the right way to create helper?




Aucun commentaire:

Enregistrer un commentaire