T

T

Source:

Template loader for loading static resources over jquery

Examples

Get Handlebar compiled HTML

$.when(T.render('/density/templates/density.html', function(src){
   self.template = src;
})).then(function () {});

Get raw resources

$.when(T.get('/density/templates/density.html', function(src){
   self.template = Handlebar.compile(src);
})).then(function () {});

Methods

(static) fetch(name)

Source:

Fetch template in sync request

Parameters:
Name Type Description
name string

Template path

(static) get(name, callback) → {Promise}

Source:

Fetch and return raw template

Parameters:
Name Type Description
name string

Template path

callback function

when done

Returns:

ajax promise

Type
Promise

(static) isCached(name) → {boolean}

Source:

Check if template is cached

Parameters:
Name Type Description
name string

Template path

Returns:

true if template is cached

Type
boolean

(static) prefetch(name)

Source:

Prefetch template

Parameters:
Name Type Description
name string

Template path

(static) render(name, callback) → {Promise}

Source:

Process and return fetched template

Parameters:
Name Type Description
name string

Template path

callback function

when done

Returns:

ajax promise

Type
Promise

(static) renderSync(name, callback)

Source:

Fetch and return raw template in sync

Parameters:
Name Type Description
name string

Template path

callback function

when done

(static) store(name, raw)

Source:

Store template in cache

Parameters:
Name Type Description
name string

Template path

raw string

Raw template data

(static) urlFor(name) → {string}

Source:

Generate request URL for template

Parameters:
Name Type Description
name string

Template path

Returns:

URL where to fetch template

Type
string