Idiomatic way to have nested routes without nesting templates

Hi all,

I’ve been building a new webapp in Ember.js for the last couple of weeks and I’ve been stuggling with and enjoying the process at the same time.

There is one seemingly simple use case that I haven’t been able to crack: having the templates for nested routes replace the parent template in a clean, idiomatic way. I posted a question on Stackoverflow (ember.js - Idiomatic Emberjs for nested routes but non-nested templates - Stack Overflow) but I haven’t gotten any feedback.

It would be great if any of you have been able to get this working cleanly and can share your approach. It has to be a fairly common pattern to have a route like:

/team/42/post/53/comments

And have the post take up the whole screen, instead of rendering it under the team template’s {{outlet}}. I may want to have a detailed team page, but once you get into posts, I may just want a “Back to Team” button and a nice full post screen.

The way I see it right now, you either render the post somewhere inside the team template or have the post route not be a child of team. I do have a workaround on the Stackoverflow question that works, but it feels hacky and fragile to me.

Please share any thoughts either here or on Stackoverflow.

Thanks for your insights,

Ike

4 Likes

I think that the problem with a back button may be a bug, in my opinion something like this should work out of the box.

I agree that it should work out of the box but it seemed to be the consensus on Stackoverflow that it just doesn’t work that way.

Anybody with a different experience? It can’t be that hard to have nested full page templates can it?

The answer in SO is the way to go. Not anything hacky :stuck_out_tongue:

Indeed, that answer was very helpful. I hadn’t seen it when I posted here. My case was actually a bit more complex than the example but the answer helped me figure it out.

You can take a look at my update there to see how I got some routes to be nested and not others.

I still think that it’s not a trivial thing to figure out. Hopefully the SO entry and this post will guide others in the future with similar requirements.

I was about to create a new post with the same question.

Thanks!

PS: God save the search function! :wink: