render (name, context, options) String
public
Calling {{render}}
from within a template will insert another template that matches the provided name. The inserted template will access its properties on its own controller (rather than the controller of the parent template). If a view class with the same name exists, the view class also will be used. Note: A given controller may only be used once in your app in this manner. A singleton instance of the controller will be created for you. Example:
1 2 3 | App.NavigationController = Ember.Controller.extend({ who: "world" }); |
1 2 | <!-- navigation.hbs --> Hello, {{who}}. |
1 2 3 | <!-- application.hbs --> < h1 >My great app</ h1 > {{render "navigation"}} |
1 2 3 4 | < h1 >My great app</ h1 > < div class = 'ember-view' > Hello, world. </ div > |
Optionally you may provide a second argument: a property path that will be bound to the model
property of the controller. If a model
property path is specified, then a new instance of the controller will be created and {{render}}
can be used multiple times with the same name.
For example if you had this author
template.
1 2 3 4 | < div class = "author" > Written by {{firstName}} {{lastName}}. Total Posts: {{postCount}} </ div > |
You could render it inside the post
template using the render
helper.
1 2 3 4 5 | < div class = "post" > < h1 >{{title}}</ h1 > < div >{{body}}</ div > {{render "author" author}} </ div > |
Parameters:
-
name
String
-
context
Object?
-
options
Hash
Returns:
-
String
- HTML string
Please login to continue.