new Engine(optsopt, formatFuncopt, loggeropt)
Creates a template literal engine
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
TemplateOpts
|
<optional> |
The |
||||||||||||||||||||
formatFunc |
function
|
<optional> |
The |
||||||||||||||||||||
logger |
Object
|
<optional> |
The logger for handling logging output
|
Members
legacyRenderOptions
The LEGACY-ONLY API TemplateOpts
to use when no rendering options
are passed (or are empty) into the rendering function and a callback function is specified when
calling Engine.compile
Methods
(static) create(cachier) → {Engine}
Creates a new Engine
from a Cachier
instance
Parameters:
Name | Type | Description |
---|---|---|
cachier |
Cachier
|
The |
Returns:
- Type:
-
Engine
The generated Engine
(async) clearCache(allopt)
Clears the underlying cache
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
all |
Boolean
|
<optional> |
false |
|
(async) compile(content, optsopt, callbackopt) → {function}
Compiles a template and returns a function that renders the template results using the passed context
object
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
content |
String
|
The raw template content |
|
opts |
Object
|
<optional> |
The options sent for compilation (omit to use the options set on the |
callback |
function
|
<optional> |
Optional callback style support for LEGACY-ONLY APIs: |
Returns:
- Type:
-
function
The rendering function(context)
that returns a template result string based upon the provided context
registerHelper(func)
Registers a directive function that can be used within template interpolations
Parameters:
Name | Type | Description |
---|---|---|
func |
function
|
A named |
registerPartial(name, contentOrParams, extensionopt) → {String}
Registers and caches a partial template
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
String
|
The template name that uniquely identifies the template content |
||
contentOrParams |
String
|
URLSearchParams
|
Either the partial template content string to register _or_ the
|
||
extension |
String
|
<optional> |
options.defaultExtension |
Optional override for a file extension designation for the partial |
Returns:
- Type:
-
String
The partial content
(async) registerPartials(partialsopt, readopt) → {Object}
Registers and caches partial compile-time partial templates
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
partials |
Array.<Object>
|
<optional> |
The partials to register
|
|||||||||||||||||
read |
Boolean
|
<optional> |
true |
When |
Returns:
- Type:
-
Object
An object that contains the registration results:
partials
Thepartials
object that contains the fragments that have been registeredname
The template name that uniquely identifies the template contentcontent
The template contentextension
The template file extension designationparams
The URLSearchParams passed during the initial content readfromRead
A flag that indicates that the
dirs
Present only whenEngine.filesEngine
was used. Contains the directories/sub-directories that were created
(async) renderPartial(name, contextopt) → {String}
On-Demand compilation of a registered template
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
String
|
The name of the registered tempalte |
||
context |
Object
|
<optional> |
{} |
The object that contains contextual data used in the template |
Returns:
- Type:
-
String
The compiled template
renderPartialGenerate() → {function}
Returns:
- Type:
-
function
A reference safe async
function to Engine.renderPartial
that can be safely passed into other functions