Dynamic Fields

Dynamic fields allow Mochi to generate content automatically instead of requiring you to type everything manually. Dynamic fields can produce audio, translations, readings, images, and other derived content based on input or from the values of other fields.

This makes templating especially powerful when creating vocabulary cards or large sets of structured study material.

What are dynamic fields?

Dynamic fields work similarly to Basic field types in that they accept an input and their value will be substituted for placeholders in the template. Dynamic fields differ from basic field types (e.g. text field) in that they produce output that is different from the input.

For example the translation dynamic field type will take some text as input and produce a translated version of the text as output.

Using other fields as input

Dynamic fields also differ from basic fields in that they can use other fields as input.

For example an Example sentence text field could be used as the input for an Example sentence (Japanese) translation field.

You can even use other dynamic fields as a source. For example you can use an Example Sentence (Japanese) AI field as the input source for an Example Sentence (English) translation field.

Tip

When using another dynamic field as the input source for a dynamic field, that source field must be present in the template markdown in order to have its dynamic content generated.

In summary, a dynamic field:

  • Has a type (e.g., translation, text-to-speech, furigana)
  • May have a source (another field to derive from)
  • Can be combined with conditional rendering to override output

Dynamic field types

The following is a list of available Dynamic fields and how they transform the input text.

  • Text to speech
    • Creates a speech audio clip from the input text.
  • Image search
    • Performs an image search with the input text.
  • Translation
    • Translates the input text from one language to another.
  • Dictionary
    • Looks up the definition of the input text in the specified dictionary.
  • Transcription
    • Takes an audio file and transcribes the speech into text.
    • Contents of the field should be a single audio file embedded as markdown. E.g. ![](my_audio_file.mp3).
  • AI Text Generator
    • Create flashcard
      • Creates a question / answer style flash card from the given text.
    • Create question
      • Generates a question based on the given statement.
    • Example sentence
      • Will create an example sentence for the given word.
    • Reword a sentence
      • Will reword the given sentence.
    • Create LaTeX expression
      • Will generate a LaTeX expression from the given text.
    • Custom
      • Send a custom prompt to the AI. If markdown is returned, it will be rendered. You can also access other fields in the prompt.
  • Chinese Pinyin
    • Adds pinyin pronunciation ruby characters to Chinese text.
  • Japanese Furigana
    • Adds Japanese furigana pronunciation ruby characters to Japanese text.

Example: A fully automated vocabulary template

Fields:

  • word — user input
  • meaning — translation from word
  • example — user input
  • tts — TTS generated from word
  • image — search from word

Template:

# <<word>>

**Meaning:** <<meaning>>

<<#image>>
![Image for <<word>>](<<image>>)
<</image>>

<<#example>>
### Example
<<example>>
<</example>>

<<#tts>>
Pronunciation
<</tts>>

With dynamic fields:

  • You only need to fill in word and (optionally) example
  • Everything else is generated automatically.

Overriding dynamic fields

The output of a dynamic field can be manually overridden using conditional rendering.

For example, suppose you had a translation field named translation, but the output text was incorrect in some way. You can create a basic text field called translation_override. Then, in your template, you can add conditional rendering such that translation is only rendered when translation_override is blank.

Example:

<<^translation_override>>
<<translation>>
<</translation_override>>
<<translation_override>>

Now, whenever the translation output is incorrect, simply fill out translation_override, and it will be rendered instead.