Here are two possible options, although for both you first need to store the currentPath in the ApplicationController in order to access it when you need it:
var App = Ember.Application.create({ currentPath: '' }); App.ApplicationController = Ember.ObjectController.extend({ updateCurrentPath: function() { App.set('currentPath', this.get('currentPath')); }.observes('currentPath') });
Using a computed property
Then, in the controller that backs up the template, let's say that you have a NavigationController , you create a computed property and also determine the dependence on the ApplicationController with API needs to collect access, and then in CP you check if the currentPath one you want:
App.NavigationController = Ember.Controller.extend({ needs: 'application', showSubMenu: function(){ var currentPath = this.get('controllers.application.currentPath'); return (currentPath === "assortmentGroup"); }.property('controllers.application.currentPath') });
So you can use a simple {{#if}} helper in your template:
... {{#linkTo "assortmentGroup" this}} {{description}} {{/linkTo}} {{#if showSubMenu}} <ul> {{#each itemCategories}} <li>{{#linkTo "itemCategory" this}} {{description}} {{/linkTo}}</li> {{/each}} </ul> {{/if}} </li> ...
Using the Special '{{#ifRoute}}' Helper
But if you really want the user assistant to deal with your state, then you can do this, note that the currentPath stored in your application is still necessary, since we need a way to get the value of the current route:
Ember.Handlebars.registerHelper('ifRoute', function(value, options) { if (value === App.get('currentPath')) { return options.fn(this); } else { return options.inverse(this); } });
And then you can use it as follows:
... {{#linkTo "assortmentGroup" this}} {{description}} {{/linkTo}} {{#ifRoute "assortmentGroup"}} <ul> {{#each itemCategories}} <li>{{#linkTo "itemCategory" this}} {{description}} {{/linkTo}}</li> {{/each}} </ul> {{/ifRoute}} </li> ...
See also a simple demo of a "custom assistant" solution: http://jsbin.com/izurix/7/edit
Note: there is a catch with the second solution! Since bound helpers do not support blocks (in the settings for coal handles), I used a simple assistant that does not overestimate the condition depending on the bindings, which may not be what you need.
Hope this helps.