Members
config
Properties| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config | object | Configuration object Properties
|
loopDetector
Properties| Name | Type | Description |
|---|---|---|
loopDetector | object | Loop detection object |
Methods
buildCompileImports(locals, req) → {TImportsResult}
Build compile imports. Used to provide utility functions to templates.
| Name | Type | Description |
|---|---|---|
locals | object | Locals object |
req | object | Request object |
Imports object
- Type:
- TImportsResult
(async) compile(content, locals, options) → {Promise.<function()>}
Compile a template with the given content and locals.
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
content | string | Template content | |||||||||
locals | object | Locals object | |||||||||
options | object | Options object Properties
|
Compiled template function
- Type:
- Promise.<function()>
getExcerpt(content, maxWords, trailChars) → {string}
Get an excerpt from the content.
| Name | Type | Description |
|---|---|---|
content | string | Content string |
maxWords | number | Maximum number of words |
trailChars | string | Trailing characters |
Excerpt
- Type:
- string
getResource(name) → {object}
Get a resource by name.
| Name | Type | Description |
|---|---|---|
name | string | Resource name |
Resource object
- Type:
- object
getTruncated(content, maxChars, trailChars) → {string}
Get a truncated version of the content.
| Name | Type | Description |
|---|---|---|
content | string | Content string |
maxChars | number | Maximum number of characters |
trailChars | string | Trailing characters |
Truncated content
- Type:
- string
(async) parseFrontMatter(input, lang) → {Promise.<object>}
Parse front matter from the input string.
| Name | Type | Description |
|---|---|---|
input | string | Input string |
lang | string | Language |
Parsed front matter
- Type:
- Promise.<object>
(async) render(tpl, locals, opts) → {Promise.<string>}
Render a template with the given locals and options.
| Name | Type | Description |
|---|---|---|
tpl | string | Template name |
locals | object | Locals object |
opts | object | Options object |
Rendered template
- Type:
- Promise.<string>
(async) renderString(content, locals, opts) → {Promise.<string>}
Render a string with the given locals and options.
| Name | Type | Description |
|---|---|---|
content | string | Content string |
locals | object | Locals object |
opts | object | Options object |
Rendered content
- Type:
- Promise.<string>
resolveLayout(item, opts) → {object}
Resolve a layout by name.
| Name | Type | Description |
|---|---|---|
item | string | Layout name |
opts | object | Options object |
Resolved layout
- Type:
- object
resolvePartial(item, opts) → {object}
Resolve a partial by name.
| Name | Type | Description |
|---|---|---|
item | string | Partial name |
opts | object | Options object |
Resolved partial
- Type:
- object
resolveResource(type, item, opts, fallbackHandler) → {object}
Resolve a resource by type and name.
| Name | Type | Description |
|---|---|---|
type | string | Resource type |
item | string | Resource name |
opts | object | Options object |
fallbackHandler | function | Fallback handler function |
Resolved resource
- Type:
- object
resolveTemplate(item, opts) → {object}
Resolve a template by name.
| Name | Type | Description |
|---|---|---|
item | string | Template name |
opts | object | Options object |
Resolved template
- Type:
- object
splitContent(input, readFile) → {object}
Split content into front matter and body.
| Name | Type | Description |
|---|---|---|
input | string | Input string or file path |
readFile | boolean | Whether to read the file |
Object containing frontMatter and content
- Type:
- object