Skip to content

Commit

Permalink
docs: note changes to custom templates in the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
praschke committed Oct 22, 2023
1 parent 3b88696 commit f88bded
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,35 @@ updates automatically.

## Migrating from Yomichan

### Exporting Data

If you are an existing user of Yomichan, you can export your dictionary collection and settings such that they can be imported into Yomitan to reflect your setup exactly as it was.

You can export your settings from Yomichan's Settings page. Go to the `Backup` section and click on `Export Settings`.

Yomichan doesn't have first-class support to export the dictionary collection. Please follow the instructions provided in the following link to export your data:
https://github.com/themoeway/yomichan-data-exporter#steps-to-export-the-data

You can them import the exported files into Yomitan from the `Backup` section of the `Settings` page. Please see [the section on importing dictionaries](#importing-dictionaries) further below for more explicit steps.
You can then import the exported files into Yomitan from the `Backup` section of the `Settings` page. Please see [the section on importing dictionaries](#importing-dictionaries) further below for more explicit steps.

### Custom Templates

If you do not use custom templates for Anki note creation, this section can be skipped.

Due to security concerns, an alternate implementation of Handlebars is being used which behaves slightly differently.
This revealed a bug in four of Yomitan's template helpers, which have now been fixed in the default templates. If your
custom templates use the following helpers, please ensure their use matches the corrected forms.

Helper | Example | Corrected
-------|---------|----------
`formatGlossary` | `{{#formatGlossary ../dictionary}}{{{.}}}{{/formatGlossary}}` | `{{formatGlossary ../dictionary .}}`
`furigana` | `{{#furigana}}{{{definition}}}{{/furigana}}` | `{{furigana definition}}`
`furiganaPlain` | `{{~#furiganaPlain}}{{{.}}}{{/furiganaPlain~}}` | `{{~furiganaPlain .~}}`
`dumpObject` | `{{#dumpObject}}{{{.}}}{{/dumpObject}}` | `{{dumpObject .}}`

Authors of custom templates may be interested to know that other helpers previously used and documented in the block
form (e.g. `{{#set "key" "value"}}{{/set}}`), while not broken by this change, may also be replaced with the less verbose
form (e.g. `{{set "key" "value"}}`). The default templates and helper documentation have been changed to reflect this.

## Dictionaries

Expand Down
12 changes: 6 additions & 6 deletions docs/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ Creates a set of all unique tags for the definition and returns a text represent
</details>


### `eachUpTo`
### `#eachUpTo`

Similar to the built-in `each` function, but iterates up to a maximum count.
Similar to the built-in `#each` function, but iterates up to a maximum count.
If the iterable is falsy or empty, the `else` condition will be used.

<details>
Expand Down Expand Up @@ -314,7 +314,7 @@ If an unknown operator is specified, the `undefined` value is returned.
<details>
<summary>Syntax:</summary>

<code>{{#op <i>operator</i> <i>operand1</i> <i>[operand2]</i> <i>[operand3]</i>}}{{/op}}</code>
<code>{{op <i>operator</i> <i>operand1</i> <i>[operand2]</i> <i>[operand3]</i>}}</code>

* _`operator`_ <br>
One of the unary, binary, or ternary operators.
Expand All @@ -329,7 +329,7 @@ If an unknown operator is specified, the `undefined` value is returned.
<summary>Example:</summary>

```handlebars
{{#if (op "===" value1 value2)}}Values are equal{{/op~}}<br>
{{#if (op "===" value1 value2)}}Values are equal{{/if~}}<br>
{{~#op "-" value1}}{{/op~}}<br>
{{~op "?:" value1 "a" "b"}}
```
Expand Down Expand Up @@ -399,7 +399,7 @@ Assigns a value to the custom state stack.
</details>


### `scope`
### `#scope`

Pushes a new variable scope to the custom state stack.
Variable assignments are applied to the most recent scope,
Expand Down Expand Up @@ -538,7 +538,7 @@ Returns an array of the mora for a kana string.

### `typeof`

Returns the type of a value.
Returns the type of a value. Use of `#typeof` in the block form may be nonportable.

<details>
<summary>Syntax:</summary>
Expand Down

0 comments on commit f88bded

Please sign in to comment.