Search code examples
javascriptmeteorhandlebars.jsspacebars

Meteor.js using value of a helper as template


I would like to render different template based on a helper value. I will try to write and example.

...
{{#with myHelper}}
 {{> this }}
{{/with}}
...

with the helper define like this for example:

...
myHelper : function(){
  return MyCollection.findOne({ userId: Meteor.userId() }).personalizeTemplate; 
}
...

Unfortunately in this way doesn't work. There could be any solution for that?


Solution

  • You need to use a dynamic template You don't even need the {{#with}}

    {{> Template.dynamic template=myHelper }}