new Template()
Skull.Template provides wrapper for template engine (_.template by default).
This wrapper performs caching, error handling and adding a bit of debugging info.
By default Skull.Template fetches templates stored in script
tags with js-tpl-<templateName>
class.
Methods
(protected) _compileTemplate(rawTemplate) → {function}
Compiles template to function
Parameters:
Name | Type | Description |
---|---|---|
rawTemplate |
String |
Returns:
- Type
- function
(protected) _getCompiledTemplate(name) → {function}
Gets compiled template by its name
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
Returns:
- Type
- function
(protected) _getTemplate(name) → {function}
Returns either cached compiled template or compiles it, caches and returns it
Parameters:
Name | Type | Description |
---|---|---|
name |
String | template name |
Returns:
compiled template
- Type
- function
(protected) _getTemplateNode(name) → {jQuery}
Fetches template by name.
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
Throws:
-
'No such template'
- Type
- Error
Returns:
- Type
- jQuery
(protected) _preprocessTemplate(node) → {String}
Primary templates processing – e.g. whitespace trimming
Parameters:
Name | Type | Description |
---|---|---|
node |
jQuery |
Returns:
- Type
- String
initialize(options)
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
tmpl(name, tplDataopt, callbackopt) → {function|String|undefined}
This normally should be only one Template method you call from other places. When provided with truthie second argument, returns rendered templates, otherwise, compiled. When provided with third argument, calls it with passing, again, rendered or compiled template.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
String | |||
tplData |
Object |
<optional> |
null | if passed, function returns rendered template. If not, compiled template. |
callback |
function |
<optional> |
null | if defined, will be called instead of returning result. |
Returns:
- Type
- function | String | undefined