Not quite exactly like that. I have posted an updated version with some styling so you can see the nesting.
Edit Note: Updated example links above to new revision to fix minor bug and use ember and ember-data latest.
Also, I have explicitly defined two variables
in every route and controller. The variables are defined in every context but they are expressed in a single template called “_variables”. This is a partial and it is rendered in the templates. I include this partial in all the other templates.
By definition a partial is just template code defined in one place and inherits the values or whatever controller and context it is in.
To better understand what is going on with the foo and bar variables you should read the section of the guide that talks about coupling of data.
I would also encourage you to play around with them and change the values and see it does what you expect. You could change the value of them or even comment them out in some controllers or routes. Then you can see what inheritance is really going on.
A NOTE ON COUPLING
In Ember.js, templates get their properties from
controllers, which decorate a model.
This means that templates know about controllers and controllers know
about models, but the reverse is not true. A model knows nothing about
which (if any) controllers are decorating it, and controller does not
know which views are presenting its properties.
Basically the template gets properties from the controller. The controller is created when the application starts up and lives for a long time. The routes, model data and templates all change and as this happens various properties of the controller get updated.
The router is really mostly about state of the application. The router is responsible for managing the URLs in your application and it is responsible for fetching the model data and setting up or manipulating the specific controllers when you change urls and states in your application.
The router is backed by a state machine and therefore this is where you put the logic to transition between different parts of your application.
On the nesting of templates look at the code example. I have tried to wrap every outlet and logical segment of template code so you can see the nesting of templates. It is using twitter bootstrap styles.
I also created a non-nest “altpost”, so you can see the effect of not nesting. Note that this loads the same data as posts, but it is just a different router, controller and template.