Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
Template renderer class (#574)
Browse files Browse the repository at this point in the history
* Convert handlebars.js to a class

* Move/rename function

* Update helper registration

* Rename helper functions

* Limit cache size

* Make render() async

* Rename and move
  • Loading branch information
toasted-nutbread authored Jun 16, 2020
1 parent b4a617c commit 6562d0c
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 175 deletions.
2 changes: 1 addition & 1 deletion ext/bg/background.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
<script src="/bg/js/dictionary-importer.js"></script>
<script src="/bg/js/deinflector.js"></script>
<script src="/bg/js/dictionary.js"></script>
<script src="/bg/js/handlebars.js"></script>
<script src="/bg/js/json-schema.js"></script>
<script src="/bg/js/media-utility.js"></script>
<script src="/bg/js/options.js"></script>
<script src="/bg/js/profile-conditions.js"></script>
<script src="/bg/js/request.js"></script>
<script src="/bg/js/template-renderer.js"></script>
<script src="/bg/js/text-source-map.js"></script>
<script src="/bg/js/translator.js"></script>
<script src="/bg/js/util.js"></script>
Expand Down
5 changes: 3 additions & 2 deletions ext/bg/js/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
* JsonSchema
* Mecab
* ObjectPropertyAccessor
* TemplateRenderer
* Translator
* conditionsTestValue
* dictTermsSort
* handlebarsRenderDynamic
* jp
* optionsLoad
* optionsSave
Expand Down Expand Up @@ -63,6 +63,7 @@ class Backend {
audioSystem: this.audioSystem,
renderTemplate: this._renderTemplate.bind(this)
});
this._templateRenderer = new TemplateRenderer();

const url = (typeof window === 'object' && window !== null ? window.location.href : '');
this.optionsContext = {depth: 0, url};
Expand Down Expand Up @@ -1230,7 +1231,7 @@ class Backend {
}

async _renderTemplate(template, data) {
return handlebarsRenderDynamic(template, data);
return await this._templateRenderer.render(template, data);
}

_getTemplates(options) {
Expand Down
172 changes: 0 additions & 172 deletions ext/bg/js/handlebars.js

This file was deleted.

Loading

0 comments on commit 6562d0c

Please sign in to comment.