Class: SC.TemplateView
Extends
SC.CoreView.
SC.TemplateView
allows you to create a view that uses the Handlebars templating
engine to generate its HTML representation.
To use it, create a file in your project called +mytemplate.handlebars+. Then,
set the +templateName+ property of your SC.TemplateView
to +mytemplate+.
Alternatively, you can set the +template+ property to any function that returns a string. It is recommended that you use +SC.Handlebars.compile()+ to generate a function from a string containing Handlebars markup.
Defined in: template.js
- Since:
- SproutCore 1.5
Field Summary
- Fields borrowed from SC.CoreView:
- isAttached, isVisibleInWindow, viewState
Instance Methods
Field Detail
templateName StringThe name of the template to lookup if no template is provided.
SC.TemplateView
will look for a template with this name in the global
+SC.TEMPLATES+ hash. Usually this hash will be populated for you
automatically when you include +.handlebars+ files in your project.
Instance Method Detail
The object from which templates should access properties.
This object will be passed to the template function each time the render method is called, but it is up to the individual function to decide what to do with it.
By default, this will be the view itself.
- Parameters:
- key
- value
Since mouseUp
events will not fire unless we return YES
to mouseDown
, the
default mouseDown
implementation returns YES if a mouseDown
method exists.
When the view is asked to render, we look for the appropriate template
function and invoke it, then push its result onto the passed
SC.RenderContext
instance.
- Parameters:
- context SC.RenderContext
- the render context
The template used to render the view. This should be a function that accepts an optional context parameter and returns a string of HTML that will be inserted into the DOM relative to its parent view.
In general, you should set the +templateName+ property instead of setting the template yourself.
- Parameters:
- key
- value