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

Chet picture Chet · Aug 25, 2013 · Viewed 20.1k times · Source

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...

Answer

Chet picture Chet · Aug 25, 2013
<li><a href="{{pathFor 'article' _id=this._id }}">{{title}}</a></li>

Thats how you pass a parameter