Template renderer internal data update (#1764)
* Add cleanup callbacks * Move requirements * Add custom data
This commit is contained in:
parent
73caeac0fb
commit
8eb9c94f8a
@ -29,6 +29,8 @@ class TemplateRenderer {
|
||||
this._stateStack = null;
|
||||
this._dataTypes = new Map();
|
||||
this._requirements = null;
|
||||
this._cleanupCallbacks = null;
|
||||
this._customData = null;
|
||||
}
|
||||
|
||||
registerDataType(name, {modifier=null, composeData=null}) {
|
||||
@ -85,15 +87,21 @@ class TemplateRenderer {
|
||||
}
|
||||
|
||||
_renderTemplate(instance, data) {
|
||||
try {
|
||||
const cleanupCallbacks = [];
|
||||
const requirements = [];
|
||||
try {
|
||||
this._customData = {};
|
||||
this._stateStack = [new Map()];
|
||||
this._requirements = requirements;
|
||||
this._cleanupCallbacks = cleanupCallbacks;
|
||||
const result = instance(data).trim();
|
||||
return {result, requirements};
|
||||
} finally {
|
||||
for (const callback of cleanupCallbacks) { callback(); }
|
||||
this._stateStack = null;
|
||||
this._requirements = null;
|
||||
this._cleanupCallbacks = null;
|
||||
this._customData = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user