diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-07-18 11:20:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-18 11:20:03 -0400 |
commit | 10a9da4d31b4837d8c48e3cd1c36a7b760691d74 (patch) | |
tree | 0212b214e749c2c525637e24e837a914a6013822 /ext/js/templates/sandbox/template-renderer-frame-main.js | |
parent | e1230c7934084e1748e70e88b98f67e05cf0cf11 (diff) |
Anki template renderer abstraction (#1839)
* Add AnkiTemplateRenderer abstraction
* Move Anki-specific template functionality into AnkiTemplateRenderer
* Add documentation comments
Diffstat (limited to 'ext/js/templates/sandbox/template-renderer-frame-main.js')
-rw-r--r-- | ext/js/templates/sandbox/template-renderer-frame-main.js | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/ext/js/templates/sandbox/template-renderer-frame-main.js b/ext/js/templates/sandbox/template-renderer-frame-main.js index bb9cac3a..15fe7781 100644 --- a/ext/js/templates/sandbox/template-renderer-frame-main.js +++ b/ext/js/templates/sandbox/template-renderer-frame-main.js @@ -16,23 +16,13 @@ */ /* globals - * AnkiNoteDataCreator - * CssStyleApplier - * JapaneseUtil - * TemplateRenderer + * AnkiTemplateRenderer * TemplateRendererFrameApi */ (async () => { - const cssStyleApplier = new CssStyleApplier('/data/structured-content-style.json'); - await cssStyleApplier.prepare(); - const japaneseUtil = new JapaneseUtil(null); - const templateRenderer = new TemplateRenderer(japaneseUtil, cssStyleApplier); - const ankiNoteDataCreator = new AnkiNoteDataCreator(japaneseUtil); - templateRenderer.registerDataType('ankiNote', { - modifier: ({marker, commonData}) => ankiNoteDataCreator.create(marker, commonData), - composeData: (marker, commonData) => ({marker, commonData}) - }); - const templateRendererFrameApi = new TemplateRendererFrameApi(templateRenderer); + const ankiTemplateRenderer = new AnkiTemplateRenderer(); + await ankiTemplateRenderer.prepare(); + const templateRendererFrameApi = new TemplateRendererFrameApi(ankiTemplateRenderer.templateRenderer); templateRendererFrameApi.prepare(); })(); |