@Hummingbird wrote:
consider the following routes:
post
: render the details about a postpost/edit
: renders editable details about the post (this might be quite different frompost
)post/comment
: renderspost
AND details about the commentThe issue here is that we need to render the
post
template in the following two routes:post
andpost/comment
. We explicitly do not want to render thepost
template on the routepost/edit
.Usually one would put stuff that should not be rendered when the child route is active in the corresponding
post/index
template. However, now we need to copy all that stuff from that template to thepost/comment
template as well.Alternatively one might put everything that needs to be shared in
post
andpost/comment
into a component. However, now we need to put all our actions into the component as well, violating the DDAU principle or we need to duplicate that logic topost
andpost/comment
controllers.Lastly, we could make use of the router service and conditionally render only
{{outlet}}
(edit) or the whole template using a simple if in ourpost
template and a computed property in the controller:showPost: computed('model', 'router.currentURL', function() { return !this.get('router').isActive('post.edit', this.model); }),
Now when the edit route is active, the parent template is not rendered. On every other child route the template gets rendered.
However this seems to be quite a workaround. Is there a better solution?
Posts: 1
Participants: 1