Properties

new TemplateManager(viewPaths, callbackWhenLoaded)

Constructor function for the templateManager

Parameters

Name Type Optional Description

viewPaths

object

 

list of template URLs. Object keys will be used as the template name. {templateName1: templateUrl1, templateName2: templateUrl2, ...}

callbackWhenLoaded

function()

 

Callback function to call when templates are loaded.

Properties

cached  Object

Contains cached template in underscore template format

viewPaths  object

Contains all templates urls

Methods

fetch(name)

Synchronously fetch a template.

Parameter

Name Type Optional Description

name

string

 

template name

isCached(name) → Boolean

Checks if a specified template is already cached

Parameter

Name Type Optional Description

name

string

 

template name

Returns

Boolean 

prefetch(name)

Preloads and cache the template as underscore templates.

Parameter

Name Type Optional Description

name

string

 

template name

render(name, variables)

Render the HTML of a template based on its name.

Parameters

Name Type Optional Description

name

string

 

template name

variables

Object

 

Object holding the variable values to replace in the template before rendering.

renderInTarget(name, variables, target)

Render the HTML of a template based on its name into a DOM target.

Parameters

Name Type Optional Description

name

string

 

template name

variables

Object

 

Object holding the variable values to replace in the template before rendering.

target

Object

 

DOM element to render the HTML into

renderSync(name)

Synchronous fetching and rendering using ajax synchronous file fetching.

Parameter

Name Type Optional Description

name

string

 

template name

store(name, raw)

Stores a template from raw html as a underscore template.

Parameters

Name Type Optional Description

name

string

 

template name

raw

string

 

template html

urlFor(name) → string

Return the path of the specified template

Parameter

Name Type Optional Description

name

string

 

template name

Returns

string 

template url