summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/anki-templates-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/settings/anki-templates-controller.js')
-rw-r--r--ext/bg/js/settings/anki-templates-controller.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/bg/js/settings/anki-templates-controller.js b/ext/bg/js/settings/anki-templates-controller.js
index c05301df..c53e4553 100644
--- a/ext/bg/js/settings/anki-templates-controller.js
+++ b/ext/bg/js/settings/anki-templates-controller.js
@@ -17,6 +17,7 @@
/* global
* AnkiNoteBuilder
+ * TemplateRenderer
* api
*/
@@ -27,6 +28,7 @@ class AnkiTemplatesController {
this._cachedDefinitionValue = null;
this._cachedDefinitionText = null;
this._defaultFieldTemplates = null;
+ this._templateRenderer = new TemplateRenderer();
}
async prepare() {
@@ -144,7 +146,7 @@ class AnkiTemplatesController {
let templates = options.anki.fieldTemplates;
if (typeof templates !== 'string') { templates = this._defaultFieldTemplates; }
const ankiNoteBuilder = new AnkiNoteBuilder({
- renderTemplate: api.templateRender.bind(api)
+ renderTemplate: this._renderTemplate.bind(this)
});
const {general: {resultOutputMode, compactGlossaries}} = options;
const note = await ankiNoteBuilder.createNote({
@@ -176,4 +178,8 @@ class AnkiTemplatesController {
input.classList.toggle('is-invalid', hasException);
}
}
+
+ async _renderTemplate(template, data, marker) {
+ return await this._templateRenderer.render(template, data, marker);
+ }
}