Answer the question
In order to leave comments, you need to log in
How to force Ember to display a different "layout" for a specific controller (route)?
Task
Display only the main page in one layout (layout), all the rest - in another (the same for all).
Specifically, on the main page, it is necessary to "nail" the footer to the bottom of the browser (window), and on the rest of the pages of the site, it must be "nailed" to the bottom of the site itself.
What I tried I
added a check of the current route to the controller and added if / else to the renderTemplate in the router to display the layout in the form I need. Code below.
App = Ember.Application.create
currentPath: ''
App.ApplicationController = Ember.Controller.extend
updateCurrentPath: (->
App.set('currentPath', @get('currentPath'))
).observes('currentPath')
isIndexPage: (->
true if @currentPath == 'index'
).property()
App.ApplicationRoute = Ember.Route.extend
renderTemplate: ->
if @get("controller.isIndexPage")
@render "window-footer"
else
@render "footer"
Answer the question
In order to leave comments, you need to log in
The question seems to have been resolved by itself.
Everything turned out to be simpler than I expected - it took only a separate outle and footer.
// application.emblem
.wrapper
if isIndexPage
= partial "header"
.main-content
= outlet index
= render index/footer
else
= partial "header"
.main-content
= outlet
= render footer
// App.IndexRoute
renderTemplate: ->
@render
outlet: 'index'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question