View

View, config, out, render, update

Methods

View

new View(options) -> View

Creates a new View.

options

OptionDefaultDescription
url loads the template from a file
text uses the provided text as the template. Example:
new View({text: '<%=user%>'})
element loads a template from the innerHTML or value of the element.
type '<' type of magic tags. Options are '<' or '['
name the element ID or url an optional name that is used for caching.
cache true in production mode, false in other modes true to cache template.

config

new View.config(options) -> undefined

Sets the defaults for Views

options

OptionDefaultDescription
type '<' type of magic tags. Options are '<' or '['
cache true true to cache template.

Prototype Methods

out

new View(options).out() -> String

Returns the compiled view code source.

render

new View(options).render(object) -> String

Returns the view rendered with object.

update

new View(options).update( {element|id} [, {url|object} ] ) -> {Function|undefined}

Updates an element with the result of rendering. If no url or object is provided, update returns a function that takes an object that can be used to update the element.

- element whose innerHTML will be updated.
- id of the element whose innerHTML will be updated.
- url of a JSON request that will be used as the object to render the template and update the element with.
- the object to render the template and update the element with.