javascript - How Do I Use a Meteor Template Helper to Edit a Value Passed as a Parameter in Iron-Router? -
how use template-helper edit value of parameter passed route created using pathfor method of iron-router???
i have template-helper:
template.registerhelper('slugify', function(obj){   return _.slugify(obj); });   in .html file have this:
{{#each menuitemsfromdb}}           {{#each arrayofmenuitems}}           <a class="item category" href="">           {{this}}           </a>           {{/each}} {{/each}}   the {{this}} in above code returns string, name of category. because have registered template helper, can slugify category by:
{{slugify this}}   and have route:
this.route('list',{     path: '/list/:category_slug',     template: 'list',     controller: 'listcontroller'   });   i can link route , pass parameter route by:
{{pathfor 'list' category_slug='the-value-i-passed'}}   but hard-coding cannot achieve desired result want.
 want dynamic using 'slugify' template helper , iron-router's pathfor method , using value of {{this}}.
what i'm trying achieve although code below doesn't work:
{{pathfor 'list' category_slug={{slugify this}} }}   what's work around achieve i'm 'trying' achieve above line????
i hoping can like:
{{pathfor 'list' category_slug=slugify(this) }}   or
{{pathfor 'list' category_slug='{{slugify this}}' }}      
long story short, you're looking not yet implemented using current syntax, although it's part of handlebars standard implementation, upon meteor spacebars based.
for moment, have create separate helper slugifies input , call within pathfor.
js
template.mytemplate.helpers({   slugified: function(){     return _.slugify(this);   } });   spacebars
{{pathfor 'list' category_slug=slugified}}   note handlebars sub-expression support planned in near future , might make way next version of meteor according pr : https://github.com/meteor/meteor/pull/4101
Comments
Post a Comment