meteormeteoritehandlebars.jsiron-router

How to pass a parameter to pathFor in Handlebars for Iron-Router with Meteorite?


I have a simple route with a parameter:

this.route('article', {
        path: '/article/:_id',
        data: function() { return Articles.findOne(this.params._id); }
    });

I would like to have use the pathFor handlebars helper here with the _id:

{{#each articles}}
<li><a href="{{pathFor 'article' _id}}">{{title}}</a></li>
{{/each}}

This doesnt work for passing the _id tag into the url though...


Solution

  • <li><a href="{{pathFor 'article' _id=this._id }}">{{title}}</a></li>
    

    Thats how you pass a parameter