I am considering upgrading my code base to the latest and greatest and making room for life without controllers and views with everything basically being a component or tree of components.
I have components pretty much everywhere apart from the top level routes like /contacts
or /contatct/:contact_id
etc.
The pattern I have used throughout my code is to use a layout for each top level view so that I can share the markup amongst all views and avoid duplication.
I might have a view like this:
App.ContactView = Ember.View.extend
layoutName: "layouts/two_column"
or
Ap.SomeOtherView = Ember.View.extend
layoutName: "layouts/single_column"
This has been very nice because I can share the markup among all the views without duplication.
My two_column
layout might look like this:
<div class="two-column-layout">
<div class="sidebar">
{{outlet sidebar}}
</div>
<div class="main-content">
{{yield}}
</div>
</div>
I then used renderTemplate
to set any outlets:
renderTemplate: ->
@render()
@render 'contact/sidebar',
into: 'contact'
outlet: 'sidebar'
How can I use layouts in the new world where I would have a top level component without duplicating my markup in each top level component?
I’ve found using layouts like this has saved me a lot of duplication and I hope there is something similar that I can use with components.