Template helper is not recalled after new Template is rendered

In my app there are certain routes which require a specific class. I’ve registered a helper which will only add this class (“background-terrain”) when the specific route is active.

<main id="panel" class="main-panel
    {{#if showBackgroundImage}}
        background-terrain
    {{/if}}">

      {{> Template.dynamic template=content}}
....
showBackgroundImage: () => {
    var routename = FlowRouter.getRouteName();
    return (routename == "signup" || routename == "login" || routename == "forgotpassword");
},

The problem is that this class does not get removed when the user navigates to other routes. The background-terrain is still in the DOM when one of the other routes becomes active.

So my question is, how does one make sure the template helper gets recalled when a new route is loaded into the Template.dynamic?

From the FlowRouter documentation

As with all current route properties, these are not reactive, but can be combined with FlowRouter.watchPathChange() to get group names reactively.

3 Likes