Annotation

The number of annotation objects injected into a template depends on the template's Context Mode. When the Context Mode is set to annotation, a single annotation object is injected into the template's context. When the Context Mode is set to book, multiple annotation objects, under the name annotations, are injected into the template's context.

Template Fields - Annotation

AttributeTypeDescription
annotationslist[dictionary]annotation objects
annotationdictionaryannotation object
annotation.bodystringbody
annotation.stylestringhighlight style/color
annotation.notesstringnotes
annotation.tagslist[string]tags
annotation.metadatadictionarymetadata
annotation.metadata.idstringunique id
annotation.metadata.book_idstringbook's unique id
annotation.metadata.createddatetimedate created
annotation.metadata.modifieddatetimedate modified
annotation.metadata.locationstringlocation string
annotation.metadata.epubcfistringepubcfi
annotation.slugsdictionaryslugs object
annotation.slugs.metadatadictionaryslugs metadata object
annotation.slugs.metadata.createdstringdate created slugified
annotation.slugs.metadata.modifiedstringdate modified slugified

Example Data - Annotation

{
  "body": "Of course it is not easy to go one’s road...",
  "style": "blue",
  "notes": "",
  "tags": [],
  "metadata": {
    "id": "9D1B71B1-895C-446F-A03F-50C01146F532",
    "book_id": "1969AF0ECA8AE4965029A34316813924",
    "created": "2021-11-02T18:04:45.184863090Z",
    "modified": "2021-11-02T18:12:30.355533123Z",
    "location": "6.26.4.2.446.2.1:0",
    "epubcfi": "epubcfi(/6/26[Part09_Split4]!/4/2/446/2/1,:0,:679)",
    "slugs": {
      "created": "2021-11-02-180445",
      "modified": "2021-11-02-180445"
    }
  }
}

Example Template - Annotation

{% for annotation in annotations -%}

---

{{ annotation.body }}

{%- if annotation.notes %}notes: {{ annotation.notes }}{% endif -%}
{%- if annotation.tags %}tags: {{ annotation.tags | join(sep=" ") }}{% endif %}

{% endfor %}

Here Tera's join filter is used to join an array of items into a space-separated string.