Constructor
new Template(filepath)
Parameters:
Name | Type | Description |
---|---|---|
filepath |
string | Templates directory. |
- Source:
Methods
load(file) → {function}
Loads template from given file.
Parameters:
Name | Type | Description |
---|---|---|
file |
string | Template filename. |
- Source:
Returns:
Returns template closure.
- Type
- function
partial(file, data) → {string}
Renders template using given data.
This is low-level function, for rendering full templates use Template.render().
Parameters:
Name | Type | Description |
---|---|---|
file |
string | Template filename. |
data |
object | Template variables (doesn't have to be object, but passing variables dictionary is best way and most common use). |
- Source:
Returns:
Rendered template.
- Type
- string
render(file, data) → {string}
Renders template with given data.
This method automaticaly applies layout if set.
Parameters:
Name | Type | Description |
---|---|---|
file |
string | Template filename. |
data |
object | Template variables (doesn't have to be object, but passing variables dictionary is best way and most common use). |
- Source:
Returns:
Rendered template.
- Type
- string