diff --git a/docs/templates.md b/docs/templates.md index 8e88a7dc..81259a3f 100644 --- a/docs/templates.md +++ b/docs/templates.md @@ -532,6 +532,119 @@ Returns an array of the mora for a kana string. +### `typeof` + +Returns the type of a value. + +
+ Syntax: + + {{#typeof value}}{{/get}}
+ {{#typeof}}value{{/get}}
+ + * _`value`_
+ The value to check. +
+
+ Example: + + ```handlebars + {{#typeof "よみちゃん"}}{{/typeof}} + {{#typeof 1}}{{/typeof}} + {{#typeof}}よみちゃん{{/typeof}} + ``` + + Output: + ```html + string + number + string + ``` +
+ + +### `join` + +Joins the arguments to a single string with a separator, flattening any arguments that are arrays. + +
+ Syntax: + + {{#join separator value1 value2 valueN...}}{{/join}}
+ + * _`separator`_
+ The separator string to use between values. + * _`valueN`_
+ An individual value to join into the resulting string +
+
+ Example: + + ```handlebars + {{#set "index" 32}}{{/set~}} + {{~#join "_" "yomichan" (get "index") "value"}}{{/join}} + ``` + + Output: + ```html + yomichan_32_value + ``` +
+ + +### `concat` + +Joins the arguments to a single string, without flattening arguments that are arrays. + +
+ Syntax: + + {{#concat value1 value1 valueN...}}{{/concat}}
+ + * _`valueN`_
+ A value to join into the resulting string +
+
+ Example: + + ```handlebars + {{#set "index" 32}}{{/set~}} + {{~#concat "yomichan_" (get "index") "_value"}}{{/concat}} + ``` + + Output: + ```html + yomichan_32_value + ``` +
+ + +### `pitchCategories` + +Returns an array representing the different pitch categories for a specific term. + +
+ Syntax: + + {{#pitchCategories @root}}{{/pitchCategories}}
+ + * _`@root`_
+ The argument passed should always be the root data object. +
+
+ Example: + + ```handlebars + [{{#each (pitchCategories @root)}}{{.}}{{#unless @last}}, {{/unless}}{{/each}}] + ``` + + Output: + ```html + [heiban, kifuku] + ``` +
+ + ## Legacy Helpers Yomichan has historically used Handlebars templates to generate the HTML used on the search page and results popup.