Skip to content

Instantly share code, notes, and snippets.

@mmun
Last active December 30, 2015 15:49
Show Gist options
  • Save mmun/7850995 to your computer and use it in GitHub Desktop.
Save mmun/7850995 to your computer and use it in GitHub Desktop.

Examples of how the controller keywork in templates works

The controller keyword in a template is inherited from the containing template unless it overrides it.

Consider this template for the index route.

{{#each posts}}
  {{controller}}
{{/each}}

If posts is an array but not an array controller then {{controller}} will be the ambient controller, IndexController. If posts is an array controller, PostsController, and does not define an item controller then {{controller}} will be PostsController. If posts is an array controller and it defines an item controller, PostController, then {{controller}} will be PostController.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment