Frontmatter Reference
The frontmatter is a YAML block that contains metadata about the template. If present, the frontmatter section must be the first thing in the file and must be valid YAML between triple-dashed lines.
whiskers
Section titled “whiskers”version
Section titled “version”The version
is the most important frontmatter key. This key ensures Whiskers
understands the template it is rendering.
Specification
Section titled “Specification”Whiskers supports specifying version requirements in a number of ways:
^X.Y.Z
: exactlyX
, with any minor and patch version >=Y.Z
. This is the recommended approach unless a more specific constraint is required.~X.Y.Z
: exactlyX.Y
, with any patch version >=Z
.=X.Y.Z
: only versionX.Y.Z
.=X.Y
or=X
: any version matchingX.Y.*
orX.*.*
.>ver
: any version newer thanver
, not includingver
.>=ver
: versionver
or newer.<ver
: any version older thanver
, not includingver
.<=ver
: versionver
or older.X.Y.*
,X.*
, or*
: wildcard, any value in the specified position.
Full technical detail of the supported version requirement syntax can be found in the semver crate documentation.
matrix
Section titled “matrix”The matrix
key allows Whiskers to render multiple outputs from a single
template.
It is defined as a list of iterables, Whiskers will generate a file for each combination of the iterables in the matrix. Two “magic iterables” are supported which means Whiskers can automatically generate the values before rendering the template:
flavor
: latte, frappe, macchiato, mochaaccent
: rosewater, flamingo, pink, mauve, red, maroon, peach, yellow, green, teal, sky, sapphire, blue, lavender
For examples, visit Matrix Mode in the concepts section.
filename
Section titled “filename”The filename
key allows Whiskers to automatically write the output to a file.
hex_format
Section titled “hex_format”The format used for rendering colors in hexadecimal can be customised with the
hex_format
frontmatter variable.
Specification
Section titled “Specification”This string is rendered as a Tera template with the following context variables:
r
,g
,b
,a
: The red, green, blue, and alpha channels of the color as lowercase 2-digit hexadecimal strings.R
,G
,B
,A
: As above, but uppercase.z
: The same asa
if the color is not fully opaque, otherwise an empty string.Z
: As above, but uppercase.
The default value of hex_format
is {{r}}{{g}}{{b}}{{z}}
.
Example
Section titled “Example”---whiskers: version: "^X.Y.Z" hex_format: "0x{{B}}{{G}}{{R}}{{A}}"---{{red.hex}}
Running whiskers example.tera -f mocha
outputs:
0xA88BF3FF
Custom Variables
Section titled “Custom Variables”You can also include custom context variables in the templating process by adding them to your template’s frontmatter.
For example, setting additional metadata and an accent color for the theme:
---whiskers: version: "^X.Y.Z" filename: "example.ini"app: "Windows9x"author: "backwardspy"accent: "mauve"---{% set darkGreen = green | sub(lightness=30) %}# Catppuccin for {{app}} by {{author}}bg = "#{{base.hex}}"fg = "#{{text.hex}}"border = "#{{flavor.colors[accent].hex}}"diffAddFg = "#{{green.hex}}"diffAddBg = "#{{darkGreen.hex}}"
Running whiskers example.tera -f mocha
outputs:
# Catppuccin for Windows9x by backwardspybg = "#1e1e2e"fg = "#cdd6f4"border = "#cba6f7"diffAddFg = "#a6e3a1"diffAddBg = "#40b436"