summaryrefslogtreecommitdiff
path: root/ext/bg/js/template-renderer-frame-api.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-10 19:28:50 -0500
committerGitHub <noreply@github.com>2021-01-10 19:28:50 -0500
commit4ed949364564f00a8b871095d030af516fc2ed6d (patch)
tree8a7ac38887874f67f2e99187f7ab3ce29496fe51 /ext/bg/js/template-renderer-frame-api.js
parent25080ac82eef83fdaa921e2a8b12261130b8ac85 (diff)
Refactor anki note building (#1223)
* Move TemplateRendererProxy creation into AnkiNoteBuilder * Simplify _stringReplaceAsync * Organize note generation * Rename API * Make the template rendering function more generic
Diffstat (limited to 'ext/bg/js/template-renderer-frame-api.js')
-rw-r--r--ext/bg/js/template-renderer-frame-api.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/bg/js/template-renderer-frame-api.js b/ext/bg/js/template-renderer-frame-api.js
index ecdc7268..4936a2af 100644
--- a/ext/bg/js/template-renderer-frame-api.js
+++ b/ext/bg/js/template-renderer-frame-api.js
@@ -19,7 +19,7 @@ class TemplateRendererFrameApi {
constructor(templateRenderer) {
this._templateRenderer = templateRenderer;
this._windowMessageHandlers = new Map([
- ['renderHandlebarsTemplate', {async: true, handler: this._onRenderHandlebarsTemplate.bind(this)}]
+ ['render', {async: true, handler: this._onRender.bind(this)}]
]);
}
@@ -27,6 +27,8 @@ class TemplateRendererFrameApi {
window.addEventListener('message', this._onWindowMessage.bind(this), false);
}
+ // Private
+
_onWindowMessage(e) {
const {source, data: {action, params, id}} = e;
const messageHandler = this._windowMessageHandlers.get(action);
@@ -51,8 +53,8 @@ class TemplateRendererFrameApi {
source.postMessage({action: `${action}.response`, params: response, id}, '*');
}
- async _onRenderHandlebarsTemplate({template, data, marker}) {
- return await this._templateRenderer.render(template, data, marker);
+ async _onRender({template, data, type}) {
+ return await this._templateRenderer.render(template, data, type);
}
_errorToJson(error) {