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

Instance Methods

Field Detail

templateName String

The 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.

templates Object
The hash in which to look for +templateName+. Defaults to SC.TEMPLATES.

Instance Method Detail

context(key, value)

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
mouseDown()

Since mouseUp events will not fire unless we return YES to mouseDown, the default mouseDown implementation returns YES if a mouseDown method exists.

render(context)

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
template(key, value)

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
update()
Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 08 2015 10:02:21 GMT-0600 (CST)