diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-08-25 21:58:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 21:58:51 -0400 |
commit | dfd52e1ecd6919094e0b45fde2ca03c30eaad01f (patch) | |
tree | 7d6e4ad9b25910e6ad29d7553999bc8910b85006 /ext/js/templates | |
parent | dd10dd601e8611d8585ce5d7c5945a0e314e86a8 (diff) |
Hiragana & katakana helpers (#1908)
* Add hiragana and katakana template helpers
* Update documentation
* Fix documentation
Diffstat (limited to 'ext/js/templates')
-rw-r--r-- | ext/js/templates/sandbox/anki-template-renderer.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js index 43092ec2..8a257bcc 100644 --- a/ext/js/templates/sandbox/anki-template-renderer.js +++ b/ext/js/templates/sandbox/anki-template-renderer.js @@ -87,7 +87,9 @@ class AnkiTemplateRenderer { ['formatGlossary', this._formatGlossary.bind(this)], ['hasMedia', this._hasMedia.bind(this)], ['getMedia', this._getMedia.bind(this)], - ['pronunciation', this._pronunciation.bind(this)] + ['pronunciation', this._pronunciation.bind(this)], + ['hiragana', this._hiragana.bind(this)], + ['katakana', this._katakana.bind(this)] ]); this._templateRenderer.registerDataType('ankiNote', { modifier: ({marker, commonData}) => this._ankiNoteDataCreator.create(marker, commonData), @@ -591,4 +593,16 @@ class AnkiTemplateRenderer { return ''; } } + + _hiragana(context, ...args) { + const ii = args.length - 1; + const value = (ii > 0 ? args[0] : args[ii].fn(context)); + return this._japaneseUtil.convertKatakanaToHiragana(value); + } + + _katakana(context, ...args) { + const ii = args.length - 1; + const value = (ii > 0 ? args[0] : args[ii].fn(context)); + return this._japaneseUtil.convertHiraganaToKatakana(value); + } } |