Reputation: 169
In my templates/application.hbs I would like to be able to set a condition to check if it is my index page I render a navigation for it, else it would render another set of navigation for in-app pages. The same for my footer. What is the best way to check this? Also, whether a user is login or not doesn't matter.
My research has lead to outdated code or convention. I'm also completely new to Ember so any help would be very much appreciated.
Here is my emblem attempt, but not working:
if eq currentRouteName="index"
= partial 'partialName'
else
= partial 'partialName2'
Second attempt works:
First run: ember install ember-truth-helpers
Add this to my application template:
if (eq currentRouteName "index")
= partial 'partialName'
else
= partial 'partialName2'
Upvotes: 0
Views: 301
Reputation: 3519
The application controller has a property currentRouteName
. You can choose which navigation to render based on its value.
In your application.hbs
{{#if (eq currentRouteName "index")}}
render navigation for your index page
{{else}}
render navigation for other pages
{{/if}}
The eq
helper comes from ember-truth-helpers
Upvotes: 1