Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

different between ember helpers for {{outlet}}, {{yield}}, {{render}} and {{partial}} [duplicate]

I am quite confused of these ember helpers. Can anyone deeply explain what the differences between them in an 'easier' way?

like image 489
eded Avatar asked Mar 06 '15 23:03

eded


People also ask

What is {{ outlet }} in Ember JS?

Here is the explanation: {{outlet}} -> This will provide a stub/hook/point into which you can render Components(Controller + View). One would use this with the render method of routes. In your case you will likely have a details route which could look like this.

What does outlet mean in ember?

The outlet is the location within the template within which a “deeper” template is rendered.

What is partial in Ember?

{{partial}} takes the template to be rendered as an argument, and renders that template in place. {{partial}} does not change context or scope. It simply drops the given template into place with the current scope.


1 Answers

As mentioned in the comment it has already been answered in other questions. Remaining one are available in the document. Please go through below details and let me know still in case of doubts.

Here is the explanation:

{{outlet}} -> This will provide a stub/hook/point into which you can render Components(Controller + View). One would use this with the render method of routes. In your case you will likely have a details route which could look like this. This would render the DetailsController with DetailsView into the outlet 'detailsOutlet' of the index template.

{{yield}} -> Denotes an area of a template that will be rendered inside of another template

{{render}} -> Renders the NavigationController and NavigationView at this place. This is helper is good for places, where the Controller and View do not change, e.g. a navigation.

{{partial}} -> The partial helper renders another template without changing the template context:

{{foo}}
{{partial "nav"}}

The above example template will render a template named "nav", which has the same context as the parent template it's rendered into, so if the "nav" template also referenced {{foo}}, it would print the same thing as the {{foo}} in the above example.

If a "_nav" template isn't found, the partial helper will fall back to a template named "nav".

like image 95
Aman Chhabra Avatar answered Sep 21 '22 05:09

Aman Chhabra