ProtectedconstructorTrue once the underlying TemplateEngineBase cache has loaded.
StaticInstanceLoads the single TemplateEngineBase metadata cache, then (re)initializes the render layer. The base runs its own AdditionalLoading (associating content/params with each template) inside its Config(); afterwards we drop any stale compiled templates and one-time-initialize the nunjucks environment.
NOTE: when this extended the base, the nunjucks setup lived in an AdditionalLoading() override that the base's Load() invoked. Under composition the base's Load() calls the BASE's AdditionalLoading, not ours, so we drive the render-layer init explicitly here after the cache is loaded.
OptionalforceRefresh: booleanOptionalcontextUser: UserInfoOptionalprovider: IMetadataProviderProtectedcreateSimple utility method to create a new Nunjucks template object and bind it to a Nunjucks environment.
the environment to bind to; defaults to the shared autoescape environment
The Global Object Store is a place to store global objects that need to be shared across the application. Depending on the execution environment, this could be the window object in a browser, or the global object in a node environment, or something else in other contexts. The key here is that in some cases static variables are not truly shared because it is possible that a given class might have copies of its code in multiple paths in a deployed application. This approach ensures that no matter how many code copies might exist, there is only one instance of the object in question by using the Global Object Store.
ProtectedgetThis method is responsible for creating a new Nunjucks template, caching it, and returning it. If the templateContentId already had a template created, it will return that template from the cache.
if true, the template will be cached, otherwise it will not be cached
ProtectedmergeMerges default values from template parameters with the provided data. Content-specific parameters take precedence over global parameters when both define the same parameter name.
The template entity containing parameter definitions
The ID of the template content being rendered
The input data provided by the caller
A new object containing merged data with defaults applied
Renders a template with the given data.
the template object to render
the template content item (within the template)
OptionalSkipValidation: booleanif true, validation is skipped entirely (or reduced to warnings depending on SuppressWarnings)
OptionalSuppressWarnings: booleanif true AND SkipValidation is true, no validation warnings are logged. When SkipValidation is true but SuppressWarnings is false, validation issues are logged as non-fatal warnings. Defaults to false.
ProtectedrenderPromisifies the Nunjucks template rendering process.
the Nunjucks template object
the data to render the template with
Simple rendering utilty method. Use this to render any valid Nunjucks Template within the Nunjucks environment created by the Template Engine without having to use the stored metadata (Templates/Template Contents/Template Params/etc) within the MJ database. This is useful when you have a template that is stored elsewhere or dynamically created and you just want to render it with some data.
Optionaloptions: { autoescape?: boolean }optional render controls. autoescape (default true) toggles HTML-entity escaping — pass
false for plain-text contexts such as email subject lines, where Acme & Co must not become Acme & Co.
Protected StaticgetReturns the singleton instance of the class. If the instance does not exist, it is created and stored in the Global Object Store. If className is provided it will be used as part of the key in the Global Object Store, otherwise the actual class name will be used. NOTE: the class name used by default is the lowest level of the object hierarchy, so if you have a class that extends another class, the lowest level class name will be used.
OptionalclassName: string
TemplateEngine is used for accessing template metadata/caching it, and rendering templates