How to add an Ember js helper?

I’m trying to add an emberjs helper to an existing plugin (discourse-tagging).

According to the ember docs, you should place a helper in app/helpers, and name it helper-name.js.

It can then be used like this: {{ helper-name value }} in templates.

However, no matter where I place the file it I get the error: “Uncaught Error: Assertion Failed: A helper named ‘helper-name’ could not be found”

I’ve tried these locations:
app/helpers/
assets/javacripts/discourse/helpers

Where should emberjs helpers be placed in plugins?

Thanks! :slightly_smiling:

In your plugin, you should add it in assets/javascripts/discourse/helpers and make sure it has a dash in the filename like test-helper.

I just tried this locally and the helper was registered. I see you tried that path and it did not. Perhaps you need to rm -rf tmp in development mode?

2 Likes