How can I access the name of the current route in the meteor when using the meteorite router?

I am creating an application using meteor and a meteorite router , and I would like to create a template helper to check if the route is specific ( {{#ifRouteIs login}}{{/ifRouteIs}} ).

+4
source share
2 answers

I had the same problem. Based on your answer, I found a working solution. It should go on the client side of Meteor.

 Handlebars.registerHelper('ifRouteIs', function (routeName, options) { if (Meteor.Router.page() === routeName) { return options.fn(this); } return options.inverse(this); }); 
+4
source

According to meteor-router README , you can get the current page with Meteor.Router.page() , so the helper might look like this:

 Handlebars.registerHelper('ifRouteIs', function (routeName) { return Meteor.Router.page() === routeName; }); 
+4
source

Source: https://habr.com/ru/post/1480160/


All Articles