HTMLBars custom helper

Hi!

For me, yesterday was day one of using Ember seriously (in the past i’ve built a couple very trivial hello world apps).

I’m trying to create a custom template helper. Any idea why the linked code isn’t working as I’d expect? I’m trying to send the model (which contains an array) to a helper that should join the array elements together as a string, but instead I get the literal string “model”.

Looking over the sample templates on the handlebars site, this should work. (I know that handlebars != htmlbars, but I had thought that htmlbars was able to grok a handlebars template.)

I think I got it fixed for you.

Here, try this out: JS Bin - Collaborative JavaScript Debugging

Awesome!

I guess I needed Ember.Handlebars.registerBoundHelper instead of Ember.Handlebars.registerHelper

Whats the purpose of Ember.Handlebars.registerHelper (I’m not certain what lead me to believe I wanted registerHelper). Looking at the API (Ember - 4.6 - Ember API Documentation) I don’t see registerHelper listed. That said there are handful of links in the API that have ‘handlebars’ and ‘htmlbars’ as part of their title and its not clear to me which one(s) I should care about.

All the same. Thanks for getting me unstuck!!

Ok I know where I got registerHelper from. This issue about creating a custom ‘join’ helper. Clearly it was written pre-htmlbar days.

Handlebars.registerHelper is a legit method, but it belongs to Handlebars proper. Also, there’s some utility behind registerBoundHelper inside Ember that wires up binding, where the plain registerHelper in the Handlebars library wouldn’t.

Hope that makes some sense.