summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/api.js38
-rw-r--r--ext/bg/js/backend.js4
-rw-r--r--ext/fg/js/api.js4
3 files changed, 23 insertions, 23 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index aba1b722..0aad436a 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -96,25 +96,25 @@ async function apiNoteView(noteId) {
return utilBackend().anki.guiBrowse(`nid:${noteId}`);
}
-async function apiTemplateRender(template, data) {
- return handlebarsRender(template, data);
-}
-
-async function apiTemplateRenderDynamic(template, data) {
- return new Promise((resolve, reject) => {
- const sequence = utilBackend().sequenceNew();
- const handler = event => {
- if (event.data.sequence === sequence) {
- resolve(event.data.result);
- window.removeEventListener('message', handler);
- }
- };
-
- window.addEventListener('message', handler);
-
- const sandbox = utilBackend().sandbox();
- sandbox.postMessage({template, data, sequence, command: 'render'}, '*');
- });
+async function apiTemplateRender(template, data, dynamic) {
+ if (dynamic) {
+ return new Promise((resolve, reject) => {
+ const sequence = utilBackend().sequenceNew();
+ const handler = event => {
+ if (event.data.sequence === sequence) {
+ resolve(event.data.result);
+ window.removeEventListener('message', handler);
+ }
+ };
+
+ window.addEventListener('message', handler);
+
+ const sandbox = utilBackend().sandbox();
+ sandbox.postMessage({template, data, sequence, command: 'render'}, '*');
+ });
+ } else {
+ return handlebarsRender(template, data);
+ }
}
async function apiCommandExec(command) {
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 9802ea7c..5061557b 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -113,8 +113,8 @@ class Backend {
forward(apiNoteView(noteId), callback);
},
- templateRender: ({template, data, callback}) => {
- forward(apiTemplateRender(template, data), callback);
+ templateRender: ({template, data, dynamic, callback}) => {
+ forward(apiTemplateRender(template, data, dynamic), callback);
},
commandExec: ({command, callback}) => {
diff --git a/ext/fg/js/api.js b/ext/fg/js/api.js
index 151882eb..4b4d9d74 100644
--- a/ext/fg/js/api.js
+++ b/ext/fg/js/api.js
@@ -45,8 +45,8 @@ function apiNoteView(noteId) {
return utilInvoke('noteView', {noteId});
}
-function apiTemplateRender(template, data) {
- return utilInvoke('templateRender', {data, template});
+function apiTemplateRender(template, data, dynamic) {
+ return utilInvoke('templateRender', {data, template, dynamic});
}
function apiCommandExec(command) {