summaryrefslogtreecommitdiff
path: root/docs/templates.md
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-07-18 13:43:11 -0400
committerGitHub <noreply@github.com>2021-07-18 13:43:11 -0400
commit637d4a2087b9e93ccd47d689411887b6c40c3992 (patch)
treef893a08502b79f8cc03b186394665dd721377bc4 /docs/templates.md
parent10a9da4d31b4837d8c48e3cd1c36a7b760691d74 (diff)
Pronunciation template helper (#1840)
* Rename field * Set up pronunication components * Fix documentation * Rename function * Update test dependencies * Fix constructor * Log errors * Add pronunciation helper * Add styleApplier argument to _getHtml/_normalizeHtml * Use getAttribute for 'class' to support namespaced elements (e.g. svg) * Update format name * Add optional tag * Update docs
Diffstat (limited to 'docs/templates.md')
-rw-r--r--docs/templates.md37
1 files changed, 35 insertions, 2 deletions
diff --git a/docs/templates.md b/docs/templates.md
index 8ee3bb0c..f1777fde 100644
--- a/docs/templates.md
+++ b/docs/templates.md
@@ -3,7 +3,7 @@
## Helpers
Yomichan supports several custom Handlebars helpers for rendering templates.
-The source code for these templates can be found [here](../ext/js/templates/sandbox/template-renderer.js).
+The source code for these templates can be found [here](../ext/js/templates/sandbox/anki-template-renderer.js).
### `dumpObject`
@@ -689,7 +689,7 @@ These functions are used together in order to request media and other types of o
The type of media to check for.
* _`args`_ <br>
Additional arguments for the media. The arguments depend on the media type.
- * _`escape`_ <br>
+ * _`escape`_ _(optional)_ <br>
Whether or not the resulting text should be HTML-escaped. If omitted, defaults to `true`.
**Available media types and arguments**
@@ -742,6 +742,39 @@ These functions are used together in order to request media and other types of o
</details>
+### `pronunciation`
+
+Converts pronunciation information into a formatted HTML content string. The display layout is the
+same as the system used for generating popup and search page dictionary entries.
+
+<details>
+ <summary>Syntax:</summary>
+
+ <code>{{#pronunciation <i>format=string</i> <i>reading=string</i> <i>downstepPosition=integer</i> <i>[nasalPositions=array]</i> <i>[devoicePositions=array]</i>}}{{/pronunciation}}</code><br>
+
+ * _`format`_ <br>
+ The format of the HTML to generate. This can be any of the following values:
+ * `'text'`
+ * `'graph'`
+ * `'position'`
+ * _`reading`_ <br>
+ The kana reading of the term.
+ * _`downstepPosition`_ <br>
+ The mora position of the downstep in the reading.
+ * _`nasalPositions`_ _(optional)_ <br>
+ An array of indices of mora that have a nasal pronunciation.
+ * _`devoicePositions`_ _(optional)_ <br>
+ An array of indices of mora that are devoiced.
+</details>
+<details>
+ <summary>Example:</summary>
+
+ ```handlebars
+ {{~#pronunciation format='text' reading='よむ' downstepPosition=1~}}{{~/pronunciation~}}
+ ```
+</details>
+
+
## Legacy Helpers
Yomichan has historically used Handlebars templates to generate the HTML used on the search page and results popup.