zk
is opened for template context extension which can be useful when creating new notes, for example:
- expanding custom metadata (author, subject, etc.)
- modifying a template's output dynamically depending on the value of an extra variable
You can declare static extra variables in the configuration file's [extra]
section. Each note group can have its own [extra]
section, which may override values from the root section.
[extra]
visibility = "public"
author = "Mickaël"
[group.journal.extra]
visibility = "private" # overrides
Maybe more useful, you can provide additional extra variables dynamically to zk new
from the command-line with --extra
. Multiple variables can be separated by a comma ,
.
$ zk new --extra author=Thomas
$ zk new --extra show-header=1,author=Thomas
After declaring extra variables, you can expand them inside the template used when creating new notes, using the usual Handlebars syntax.
# {{title}}
Written by {{extra.author}}.
{{#if extra.show-header}}
Behold, the mighty dynamic header!
{{/if}}