lundi 8 juin 2015

Change in template depending on whether a child route is active

I'm looking for a way for templates to change depending on whether a child route is active or not.

Let's say we have the routes /post/1/ and /post/1/comments.

I'd like post.hbs to be able to do something like this:

<div class={{if isChildRouteActive 'compact' 'expanded'}}>...</div>
{{outlet}}

Such that /post/1 would yield isChildRouteActive=false and /posts/1/comments would yield isChildRouteActive=true.

One could conceptualize it this way:

{{#if outlet}}...{{else}}...{{/if}}

How can I expose this property to all of my templates?




Aucun commentaire:

Enregistrer un commentaire