diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-06-26 17:43:07 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-26 17:43:07 -0400 |
commit | 8eb9c94f8a651a702347454fee9512f34bd44cb4 (patch) | |
tree | 967521688ec525699937a291c3d0f7bbb6cfab68 /ext/js/templates | |
parent | 73caeac0fba13f83a810eab27dbc0aa49b3e9ef3 (diff) |
Template renderer internal data update (#1764)
* Add cleanup callbacks
* Move requirements
* Add custom data
Diffstat (limited to 'ext/js/templates')
-rw-r--r-- | ext/js/templates/template-renderer.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/js/templates/template-renderer.js b/ext/js/templates/template-renderer.js index e27ad03c..a06298aa 100644 --- a/ext/js/templates/template-renderer.js +++ b/ext/js/templates/template-renderer.js @@ -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) { + const cleanupCallbacks = []; + const requirements = []; try { - const requirements = []; + 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; } } |