aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-07 15:20:45 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-07 21:47:48 -0500
commit7ac1c843a92cbefd0a625f06b5093217b585f7cf (patch)
tree291abdc5aaa3e9347676c1aa452192ddc8184c0d /ext/bg/js/backend.js
parent69cce49b0d5d9f11f4ffb529ae3d060536297c07 (diff)
Use dependency injection for apiTemplateRender
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r--ext/bg/js/backend.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 929281da..6e5235ed 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -31,7 +31,7 @@ class Backend {
this.anki = new AnkiNull();
this.mecab = new Mecab();
this.clipboardMonitor = new ClipboardMonitor({getClipboard: this._onApiClipboardGet.bind(this)});
- this.ankiNoteBuilder = new AnkiNoteBuilder();
+ this.ankiNoteBuilder = new AnkiNoteBuilder({renderTemplate: this._renderTemplate.bind(this)});
this.options = null;
this.optionsSchema = null;
this.defaultAnkiFieldTemplates = null;
@@ -507,7 +507,7 @@ class Backend {
}
async _onApiTemplateRender({template, data}) {
- return handlebarsRenderDynamic(template, data);
+ return this._renderTemplate(template, data);
}
async _onApiCommandExec({command, params}) {
@@ -811,6 +811,10 @@ class Backend {
definition.screenshotFileName = filename;
}
+ async _renderTemplate(template, data) {
+ return handlebarsRenderDynamic(template, data);
+ }
+
static _getTabUrl(tab) {
return new Promise((resolve) => {
chrome.tabs.sendMessage(tab.id, {action: 'getUrl'}, {frameId: 0}, (response) => {