work on sandbox

This commit is contained in:
Alex Yatskov 2017-09-05 21:10:19 -07:00
parent 722ddf1638
commit 083999212e
3 changed files with 21 additions and 21 deletions

View File

@ -96,11 +96,8 @@ async function apiNoteView(noteId) {
return utilBackend().anki.guiBrowse(`nid:${noteId}`); return utilBackend().anki.guiBrowse(`nid:${noteId}`);
} }
async function apiTemplateRender(template, data) { async function apiTemplateRender(template, data, dynamic) {
return handlebarsRender(template, data); if (dynamic) {
}
async function apiTemplateRenderDynamic(template, data) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const sequence = utilBackend().sequenceNew(); const sequence = utilBackend().sequenceNew();
const handler = event => { const handler = event => {
@ -115,6 +112,9 @@ async function apiTemplateRenderDynamic(template, data) {
const sandbox = utilBackend().sandbox(); const sandbox = utilBackend().sandbox();
sandbox.postMessage({template, data, sequence, command: 'render'}, '*'); sandbox.postMessage({template, data, sequence, command: 'render'}, '*');
}); });
} else {
return handlebarsRender(template, data);
}
} }
async function apiCommandExec(command) { async function apiCommandExec(command) {

View File

@ -113,8 +113,8 @@ class Backend {
forward(apiNoteView(noteId), callback); forward(apiNoteView(noteId), callback);
}, },
templateRender: ({template, data, callback}) => { templateRender: ({template, data, dynamic, callback}) => {
forward(apiTemplateRender(template, data), callback); forward(apiTemplateRender(template, data, dynamic), callback);
}, },
commandExec: ({command, callback}) => { commandExec: ({command, callback}) => {

View File

@ -45,8 +45,8 @@ function apiNoteView(noteId) {
return utilInvoke('noteView', {noteId}); return utilInvoke('noteView', {noteId});
} }
function apiTemplateRender(template, data) { function apiTemplateRender(template, data, dynamic) {
return utilInvoke('templateRender', {data, template}); return utilInvoke('templateRender', {data, template, dynamic});
} }
function apiCommandExec(command) { function apiCommandExec(command) {