Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can search the Ember.JS source for all of these by searching for: <code>Ember.Handlebars.registerHelper('?'</code>. For example, to find the part where <code>template</code> is defined, search for: <strong>Ember.Handlebars.registerHelper('template'</strong></p> <p><strong>{{template}}</strong></p> <p>Is similar to the <code>{{partial}}</code>, but looks for templates that you define in the <code>Ember.TEMPLATES</code> hash. From the source code we can see an example: <code>Ember.TEMPLATES["my_cool_template"] = Ember.Handlebars.compile('&lt;b&gt;{{user}}&lt;/b&gt;');</code> and then we can render it that way.</p> <p>I heard a whisper that <code>{{template}}</code> is <strong>@deprecated</strong>, but I can't find where I found that information at the moment. However, it's worth mentioning that I've never found myself using this one. Instead I prefer <code>{{partial}}</code>.</p> <p><strong>Edit:</strong> It appears as though it isn't <strong>@deprecated</strong> as of <code> 3df5ddfd4f</code>. My mistake!</p> <p><strong>{{partial}}</strong></p> <p>This is different to the <code>{{render}}</code> approach in that the <code>controller</code> and <code>view</code> are inherited from the context that called it. For example, if you're in the <code>UserRoute</code>, and you load in a partial in your user template, then the <code>UserView</code> and <code>UserController</code> will both be passed to your partial, so they can access exactly the same information as its current parent.</p> <p>Partial names, when defined, start with an underscore. For instance, a <code>Profile</code> partial will have the <code>data-template-name</code> of: <code>data-template-name="_profile"</code> but is inserted into your view as <code>{{partial "profile"}}</code>.</p> <p><strong>{{outlet}}</strong></p> <p>You'll probably find yourself using this one a lot. It's predominantly used in cases where the <code>outlet</code> changes frequently, based on user interactions. By transitioning to (<code>this.transitionTo</code>/<code>{{#linkTo}}</code>) another page, Ember inserts the view into the <code>{{outlet}}</code> and attaches the relevant <code>controller</code> and <code>view</code>.</p> <p>As an example, if you're transitioning into <em>/#/pets</em> then, by default, Ember will load the <code>PetsView</code> into the <code>{{outlet}}</code>, and attach the <code>PetsController</code>, all of this after initialising the <code>PetsRoute</code> to take instructions before initialising the view and finding the controller.</p> <p><strong>{{render}}</strong></p> <p>This is a mixture of an <code>{{outlet}}</code> and a <code>{{partial}}</code>. It's used for static pages that don't switch out for other pages (as an <code>outlet</code> does), but it doesn't inherit the controller and view (as a <code>partial</code> does).</p> <p>It's better with an example. Let's say you've got a navigation. Usually you'll only have one navigation, and it won't change for another one, but you want the navigation to have its own controller and view, and not to be inherited from the context (probably <code>ApplicationRoute</code>). Therefore when you insert the navigation (<code>{{render "navigation"}}</code>), Ember will attach <code>App.NavigationController</code> and <code>App.NavigationView</code>.</p> <p><strong>Summary</strong></p> <ul> <li><code>template</code>: Consults a global hash and inserts the view when it finds it (possibly soon to be <strong>@deprecated</strong>);</li> <li><code>partial</code>: Used to split up complicated views, and inherits the controller/view from the parent (if you're in the <code>UserController</code>, then the partial will also have access to this, and its associated view).</li> <li><code>outlet</code>: Most widely used, and allows you to quickly switch out pages for other pages. Relevant controller/view attached.</li> <li><code>render</code>: Similar to an outlet, but is used for pages that are persistent across the entire application. Assumes the relevant controller/view, and <strong>doesn't</strong> inherit them.</li> </ul> <p>Did I explain them well?</p> <p>Just to clarify:</p> <ul> <li>Partial: Inherited controller, inherited view, non-switchable;</li> <li>Outlet: Relevant controller, relevant view, switchable;</li> <li>Render: Relevant controller, relevant view, non-switchable;</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload