Is there any way I can pass an helper within another helper in a spacebars tag?
I’m trying to use in a button template that creates the same button with different values (create account, forgot password, next, …) depending on the context. When I call the button template I pass the value (create account, forgot password, next, …) so this is a simple pattern.
The problem is that I’m trying to use i18n (the tap:i18n package) so instead of a string “Forgot Password”, I should use {{_ "forgotPassword"}} and this is not possible: {{> buttonSecondary buttonSecondaryContent=_ "createAccount"}}
Is there a way of doing this while keeping this pattern as simple as it is?
a) just pass the i18n key and in the buttonSecondary template use the _ helper to get the actual text or
b) use UI.contentBlock instead (and this should be the preferred solution, because your intention is to pass content, not just some attribute or a small bit of text):
And as for nesting helpers within helpers… I think there was some way of doing it, but I can’t recall. It’s rarely useful and I haven’t needed that kind of thing in the last bunch of projects. There seem better ways of doing that.
Like creating another helper that will return/invoke another template with the params you need and/or read params from the context and pass them on to whoever needs them etc.
Just use one of the solutions above (b in this case if you can!) or unwind your thinking and restructure it. There are many other ways of accomplishing the same thing.
Thanks Iai. That’s exactly what I need: no hassle, no fuss. I’ll be waiting for that instead.
As a second thought, I’ll be using seeekr’s solution while waiting for that new feature, so thank you as well