Class: Environment
Shared configuration from which templates can be loaded and parsed.
See
Constructors
new Environment()
new Environment(
options):Environment
Environment constructor.
Parameters
• options: EnvironmentOptions = {}
Environment options.
Returns
Defined in
Properties
autoEscape
autoEscape:
boolean
Defined in
filters
readonlyfilters:object={}
An object mapping filter names to filter functions.
Index Signature
[keys: string]: Filter
Defined in
globals
globals:
ContextScope
Defined in
loader
loader:
Loader
Defined in
localNamespaceLimit
localNamespaceLimit:
number
Defined in
loopIterationLimit
loopIterationLimit:
number
Defined in
maxContextDepth
maxContextDepth:
number
Defined in
renderStreamFactory()
renderStreamFactory: (
stream?) =>RenderStream
Parameters
• stream?: RenderStream
Returns
Defined in
statementEndString
readonlystatementEndString:string
Defined in
statementStartString
readonlystatementStartString:string
Defined in
strictFilters
strictFilters:
boolean
Defined in
tagEndString
readonlytagEndString:string
Defined in
tagStartString
readonlytagStartString:string
Defined in
tags
readonlytags:object={}
An object mapping tag names to tag implementations.
Index Signature
[keys: string]: Tag
Defined in
templateClass
protectedtemplateClass: typeofTemplate=Template
Defined in
undefinedFactory()
readonlyundefinedFactory: (name) =>Undefined
Parameters
• name: string
Returns
Defined in
Accessors
outputStreamLimit
getoutputStreamLimit():number
setoutputStreamLimit(value):void
Parameters
• value: number
Returns
number
Defined in
parser
getparser():Parser
Returns
Defined in
Methods
addFilter()
addFilter(
name,filter):void
Add a filter to this environment.
Parameters
• name: string
The filter's name, as used by template authors to apply the filter.
• filter: Filter
A function implementing the filter.
Returns
void
Defined in
addTag()
addTag(
name,tag):void
Add a tag to this environment.
Parameters
• name: string
The tag's name, as used by template authors to use the tag.
• tag: Tag
An object implementing the Tag interface.
Returns
void
Defined in
error()
error(
err):void
Re-throw an error.
Override this method if you want to implement a "lax mode".
Parameters
• err: Error
Returns
void
Defined in
fromString()
fromString(
source,globals?,templateContext?):Template
Parse the given string as a Liquid template.
Parameters
• source: string
The Liquid template source code.
• globals?: ContextScope
An optional object who's properties will be added to the render context every time the resulting template is rendered.
• templateContext?: TemplateContext = {}
Optional meta data. Mostly for managing loading and reloading of templates.
Returns
A Template bound to this environment, ready to be rendered.
Throws
NoSuchTemplateError if a template with the given name can not
be found.
Defined in
getTemplate()
getTemplate(
name,globals?,context?,loaderContext?):Promise<Template>
Load a template using the configured template loader.
Parameters
• name: string
The name or identifier of the template to load.
• globals?: ContextScope
An optional object who's properties will be added to the render context every time the resulting template is rendered.
• context?: RenderContext
A reference to the active render context, if one is active.
• loaderContext?
Additional, arbitrary data that a loader can use to scope or otherwise narrow its search space.
Returns
Promise<Template>
A Template bound to this environment, ready to be rendered.
Throws
NoSuchTemplateError if a template with the given name can not
be found.
Defined in
getTemplateSync()
getTemplateSync(
name,globals?,context?,loaderContext?):Template
A synchronous version of Environment.getTemplate().
Parameters
• name: string
• globals?: ContextScope
• context?: RenderContext
• loaderContext?
Returns
See
Defined in
makeGlobals()
protectedmakeGlobals(templateGlobals?):ContextScope
Parameters
• templateGlobals?: ContextScope
Returns
Defined in
parse()
protectedparse(source,name?):Root
Parameters
• source: string
• name?: string
Returns
Defined in
getImplicitEnvironment()
staticgetImplicitEnvironment(options):Environment
Return an environment configured with the given options. The globals
and loader options are ignored when creating implicit environments.
Parameters
• options: EnvironmentOptions = {}
Options for the implicit environment.