Search code examples
node.jsmongodbmeteoriron-router

Pass parameters from Router to Template's helper on Meteor


I have a router defined as follows

Router.route('/profile/:input',function(){
    this.render('profile');
});

So I can get the value of input calling this.params.input. I want to query on MongoDB for this value and pass to the template Profile. But how can I exchange this information from the Router to the helper?

if (Meteor.isClient) {
    Template.profile.helpers({
        data: function(){
           //what to do?!
        }
    });
}

Solution

  • Inside of your Template.foo.helpers, you can grab router params by:

    Router.current().params.input