Skip to content

style1 — the default highlight list template ​

This is the default template function shipped with WuCai.

  • prefix — string prepended to each highlight
  • suffix — string appended to each highlight
  • anno — string prepended to the annotation
  • refid — boolean, whether to append the block id to the highlight
  • Colour options
    • color_tags — array mapping colours to tags
    • color — string used as a colour block
    • color_line — boolean, highlight the whole line
    • (if none of the three are set, no colour is applied)
  • Links inside highlights
    • links — boolean, whether to merge links in the highlight into the highlight itself (>= 24.8.21)

Colour block before the highlight ​

jinja
{{ item | style1({prefix:"> ", anno:"> __note__: ", color:"█  "}) }}

style1 demo with a colour block

Colour the whole highlight ​

jinja
{{ item | style1({prefix:"> ", anno:"> __note__: ", color_line:true}) }}

style1 demo with a coloured line

Append the block id ​

jinja
{{ item | style1({prefix:"> ", anno:"> __note__: ", color:"█  ", refid:true}) }}

style1 demo with block id

style_dailynote (Daily messages only) ​

A template built for Daily messages, grouping them by date (to the minute) by default.

Use isdailynote to check whether the current note is a Daily note.

Note that style_dailynote takes highlights as its argument.

Example:

jinja
{% block highlights %}
{% if isdailynote  %}
## Daily note
{{highlights|style_dailynote}}
{% else %}
## Highlights
{% for item in highlights %}
{{ item | style1({prefix:"> ", anno:"> __note__: ", color:"█  "}) }}
{% endfor %}
{% endif %}
{% endblock %}

date ​

Formats a timestamp.

jinja
{{ createat_ts | date("YYYY-MM-DD") }}        -> 2023-02-08
{{ createat_ts | date("YYYY/MM/DD HH:mm:ss") }} -> 2023/02/08 10:12:34

YYYY year, MM month, DD day, HH hour, mm minute, ss second.

More format tokens

yaml_text ​

Use this when a value contains line breaks and needs to go into the property area.

jinja
pagenote: {{ pagenote | yaml_text }}

yaml_field ​

A convenience function for the property area — it simplifies the template and improves performance.

Instead of:

jinja
{% if tags %}
tags: {{tags}}
{% endif %}

you can write:

jinja
{{tags | yaml_field("tags:") }}

yaml_list ​

Converts a list into an Obsidian property value.

Template engine ​

Templates are rendered by nunjucks.