diff options
Diffstat (limited to 'ext/js/templates/template-renderer-frame-api.js')
-rw-r--r-- | ext/js/templates/template-renderer-frame-api.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/js/templates/template-renderer-frame-api.js b/ext/js/templates/template-renderer-frame-api.js index 104e357b..dd6be517 100644 --- a/ext/js/templates/template-renderer-frame-api.js +++ b/ext/js/templates/template-renderer-frame-api.js @@ -20,6 +20,7 @@ class TemplateRendererFrameApi { this._templateRenderer = templateRenderer; this._windowMessageHandlers = new Map([ ['render', {async: false, handler: this._onRender.bind(this)}], + ['renderMulti', {async: false, handler: this._onRenderMulti.bind(this)}], ['getModifiedData', {async: false, handler: this._onGetModifiedData.bind(this)}] ]); } @@ -58,6 +59,10 @@ class TemplateRendererFrameApi { return this._templateRenderer.render(template, data, type); } + _onRenderMulti({items}) { + return this._serializeMulti(this._templateRenderer.renderMulti(items)); + } + _onGetModifiedData({data, type}) { const result = this._templateRenderer.getModifiedData(data, type); return this._clone(result); @@ -82,6 +87,17 @@ class TemplateRendererFrameApi { }; } + _serializeMulti(array) { + for (let i = 0, ii = array.length; i < ii; ++i) { + const value = array[i]; + const {error} = value; + if (typeof error !== 'undefined') { + value.error = this._serializeError(error); + } + } + return array; + } + _clone(value) { return JSON.parse(JSON.stringify(value)); } |