App.template

The App.template module handles Handlebars templates. If precompiled templates is used add them to the App.templates.compiled namespace, and they will automatically be picked up by the getTemplate() function.

Example
// Example of how fetch a template
App.template.getTemplate('/my/template');

// It is also possible to fetch an template from an provided url
App.template.getTemplate('/my/template', '/url/to/my/template.handlebars');

Members

(static) App.templates

Methods

(static) compileTemplate(name, urlopt) → {Promise}

compileTemplate returns a compiled handlebars template.

It will first try to fetch the template from the list of precompiled templates.

If the template is not found, it will fetch the template the server and compile it. Subsequent requests for the same template name will be returned from the list of compiled templates.

Parameters:
Name Type Attributes Description
name String

of the handlebars template

url String <optional>

Url from where to fetch the template from, defaults to App.info.contextURL + name + '.handlebars'

Returns:

Promise that will resolve to the compiled Handlebar template

Type
Promise

(static) getTemplate(name, urlopt) → {function}

getTemplate returns a compiled handlebars template.

It will first try to fetch the template from the list of precompiled templates.

If the template is not found, it will fetch the template the server and compile it. Subsequent requests for the same template name will be returned from the list of compiled templates.

Parameters:
Name Type Attributes Description
name String

of the handlebars template

url String <optional>

Url from where to fetch the template from, defaults to App.info.contextURL + name + '.handlebars'

Returns:

Compiled Handlebar template

Type
function

(static) initHandlebars()

(static) isPartialRegistered(name) → {Boolean}

Checks if a partial is registred or not

Parameters:
Name Type Description
name String

Name of the partial to check for existence

Returns:

boolean Boolean whether the partial is registred or not

Type
Boolean

(static) setupHelper(name, fn)

Parameters:
Name Type Description
name String

of the helper

fn String

the JavaScript function

(static) setupPartial(name, src)

Registers an Handlebars partial

Example
// Will register a partial with the name 'topbar-components'
App.templates.setupPartial('topbar-components', 'helium/templates/topbar/partials/components');
// The partial can later be called from a template using the following syntax \{{> topbar-components}}
Parameters:
Name Type Description
name String

of the partial

src String

the lookup name for the partial