Methods
#
(static) compile(key, src) → {function}
Compiles a template.
This method caches the precompiled version of the template
and returns the compiled template. The template can be accessed
directly via Handlebars.templates[key]
.
Parameters:
Name |
Type |
Description |
key |
string
|
Identifier of the template to be compiled. |
src |
string
|
The actual template source to be compiled. |
#
(static) empty() → {string}
A precompiled empty template function.
#
(static) get(key, compileopt) → {function}
Retrieves a compiled Handlebars template.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
key |
string
|
|
|
Identifier of the template to be retrieved. |
compile |
boolean
|
<optional>
|
true
|
Force the template to compile if we
have uncompiled source. |
#
(static) getField(type, view, module, fallbackTemplateopt) → {function}
Gets the compiled template for a field.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
type |
string
|
|
|
Field type. |
view |
string
|
|
|
View name. |
module |
string
|
|
|
The module the field is from. |
fallbackTemplate |
boolean
|
<optional>
|
true
|
Template name to fall back
to if the template for view is not found. |
#
(static) getLayout(nameopt, moduleNameopt) → {function}
Gets the compiled template for a layout.
Parameters:
Name |
Type |
Attributes |
Description |
name |
string
|
<optional>
|
Layout name. |
moduleName |
string
|
<optional>
|
Module name. |
#
(static) getView(name, moduleopt) → {function}
Gets the compiled template for a view.
Parameters:
Name |
Type |
Attributes |
Description |
name |
string
|
|
View name. |
module |
string
|
<optional>
|
Module name. |
#
(static) init()
Loads templates from local storage and populates the Handlebars.templates
collection.
#
(static) set(metadata, forceopt)
Registers view, layout, and field templates from metadata payload
for later "lazy" on-demand compilation.
The metadata must contain the following sections:
{
// This should now be deprecated
"view_templates": {
"detail": HB template source,
"list": HB template source,
// etc.
},
"sugarFields": {
"text": {
"templates": {
"default": HB template source,
"detail": HB template source,
"edit": ...,
"list": ...
}
},
"bool": {
// templates for boolean field
},
// etc.
}
"views": {
"text": {
"templates" {
"view": HB template source...
"view2": HB template source..
}.
}
}
Parameters:
Name |
Type |
Attributes |
Default |
Description |
metadata |
Object
|
|
|
Metadata payload. |
force |
boolean
|
<optional>
|
false
|
Flag indicating if the cache is
ignored and the templates are to be recompiled. |
#
(static) setField(type, view, module, src, forceopt) → {function}
Compiles a field template and puts it into local storage.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
type |
string
|
|
|
Field type. |
view |
string
|
|
|
View name. |
module |
string
|
|
|
The module the field is from. |
src |
string
|
|
|
Template source code. |
force |
boolean
|
<optional>
|
false
|
Flag indicating if the template must
be re-compiled. |
#
(static) setLayout(name, moduleNameopt, src, forceopt) → {function}
Compiles a layout template and puts it into local storage.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
name |
string
|
|
|
Layout name. |
moduleName |
string
|
<optional>
|
|
Module Name. |
src |
string
|
|
|
Template source code. |
force |
boolean
|
<optional>
|
false
|
Flag indicating if the template must
be re-compiled. |
#
(static) setView(name, module, src, forceopt) → {function}
Compiles a view template and puts it into local storage.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
name |
string
|
|
|
View name. |
module |
string
|
|
|
Module name. |
src |
string
|
|
|
Template source code. |
force |
boolean
|
<optional>
|
false
|
Flag indicating if the template must
be re-compiled. |