@twisted1919 wrote:
I have a basic scenario where i have to show different layout to guests vs authenticated users.
I tried to render other template than the application one by using below code in my route file:renderTemplate(){ this.render('login', { // the template to render into: 'guest', // the template to render into // outlet: 'login', // the name of the outlet in that template // controller: 'login' // the controller to use for the template }); }
but when i do so i get
Uncaught Error: Assertion Failed: You attempted to render into 'guest' but it was not found
even though the files are all there which seems to be a bug(?).The only way i managed to get this working is to output only
{{outlet}}
into theapplication.hbs
template then in all my other templates do something like:{{title "Login"}} {{partial "partial/guest-header"}} ...markup... {{partial "partial/guest-footer"}}
which get rendered in app.hbs {{outlet}}, but this seems very tedious to maintain.
I also tried to edit application.js as in:
renderTemplate(){ if (this.router.currentRouteName == "login") { this.render('guest'); } else { this.render('application'); } }
But seems that
this.router.currentRouteName
is undefined at init and in order to make it work i have to place it into aEmber.run.later
call, which again, seems very odd to do.So, that being said, what is the proper way to use various layouts? I mean, why is this so hard to achieve, is like i am fighting the framework (most likely i am) ?
Posts: 2
Participants: 1