2
votes

I am trying to include a template based on a path in another template. I got it working more or less but still have some issues and maybe someone here can put me on the right path.

I already use

{{> UI.dynamic template=route }}

with a helper to parse the URL and return the proper template name, however couple issues that I have:

1) When I click a link, Iron::Router recognizes the change however the template doesn't realize it - almost like it didn't reload even though I hit a static link.

2) Iron::Router has an catch-all that capture any main request and passes it through to the proper template, however if I have the following path for example, I get the not-found page, e.g:

/settings  -> works
/settings/profile -> 404

My catch all is this:

this.route("/:path?", function() {

});
1

1 Answers

0
votes

Try this helper to get the current route name.

UI.registerHelper("currentRouteName",function(){
    return Router.current()?Router.current().route.getName():"";
});

Then you may have to do something like:

var thisRoute = Router.current().route.getName().split("/")

and match the route you're looking for against

'/' + thisRoute[1] + '/';

The helper is from meteor js iron router: apply CSS change whenever route changes and applies to css but may be helpful to take a look at for your use case.