How do I use spacebar to pass dynamic helpers in template?
eg. {{> yo name=titleA}} {{> yo name=titleB}} {{> yo name=titleC}}
but then I have to write 3 helpers.
Can I have something like {{>yo name={{title A}} }}
so that I only need to write one help?
You can do this with global helpers and passing parameters into your template like this:
// parent template
{{> yo name='titleA'}}
// and in a client lib, declare a global template helper
Template.registerHelper({
doSomethingByTitle: function () {...}
});
// yo template
<div> {{ doSomethingByTitle this.name }} </div>
// please use `<code>` to format single line code or wrap in
//```
//multiline code
//```
I find my answer but it’s currently in spacebar devel.
Hope they publish soon
https://github.com/meteor/meteor/tree/devel/packages/spacebars#nested-sub-expressions
1 Like
Currently, I use this package : https://atmospherejs.com/raix/eventemitter, to change dynamic data between parent template vs child template.