aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/template-renderer.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-11-29 13:09:02 -0500
committerGitHub <noreply@github.com>2020-11-29 13:09:02 -0500
commit34451ebf7122a2a5d140696215411abfb0dfe188 (patch)
treee9eddb52f133269853059372045dea510e8d02dc /ext/bg/js/template-renderer.js
parenta8cd03cbecf4015483ce3479e589e65ce7eece45 (diff)
JapaneseUtil normalization (#1076)
* Use JapaneseUtil as a class which is manually instantiated * Use alias function for toKana
Diffstat (limited to 'ext/bg/js/template-renderer.js')
-rw-r--r--ext/bg/js/template-renderer.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/bg/js/template-renderer.js b/ext/bg/js/template-renderer.js
index c1995acd..6a76a4e6 100644
--- a/ext/bg/js/template-renderer.js
+++ b/ext/bg/js/template-renderer.js
@@ -17,11 +17,11 @@
/* global
* Handlebars
- * jp
*/
class TemplateRenderer {
- constructor() {
+ constructor(japaneseUtil) {
+ this._japaneseUtil = japaneseUtil;
this._cache = new Map();
this._cacheMaxSize = 5;
this._helpersRegistered = false;
@@ -119,7 +119,7 @@ class TemplateRenderer {
_furigana(context, ...args) {
const {expression, reading} = this._getFuriganaExpressionAndReading(context, ...args);
- const segs = jp.distributeFurigana(expression, reading);
+ const segs = this._japaneseUtil.distributeFurigana(expression, reading);
let result = '';
for (const seg of segs) {
@@ -135,7 +135,7 @@ class TemplateRenderer {
_furiganaPlain(context, ...args) {
const {expression, reading} = this._getFuriganaExpressionAndReading(context, ...args);
- const segs = jp.distributeFurigana(expression, reading);
+ const segs = this._japaneseUtil.distributeFurigana(expression, reading);
let result = '';
for (const seg of segs) {
@@ -161,6 +161,7 @@ class TemplateRenderer {
}
_kanjiLinks(context, options) {
+ const jp = this._japaneseUtil;
let result = '';
for (const c of options.fn(context)) {
if (jp.isCodePointKanji(c.codePointAt(0))) {
@@ -385,10 +386,10 @@ class TemplateRenderer {
}
_isMoraPitchHigh(context, index, position) {
- return jp.isMoraPitchHigh(index, position);
+ return this._japaneseUtil.isMoraPitchHigh(index, position);
}
_getKanaMorae(context, text) {
- return jp.getKanaMorae(`${text}`);
+ return this._japaneseUtil.getKanaMorae(`${text}`);
}
}