Skip to content

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.

The version is the most important frontmatter key. This key ensures Whiskers understands the template it is rendering.

Whiskers supports specifying version requirements in a number of ways:

  • ^X.Y.Z: exactly X, with any minor and patch version >= Y.Z. This is the recommended approach unless a more specific constraint is required.
  • ~X.Y.Z: exactly X.Y, with any patch version >= Z.
  • =X.Y.Z: only version X.Y.Z.
  • =X.Y or =X: any version matching X.Y.* or X.*.*.
  • >ver: any version newer than ver, not including ver.
  • >=ver: version ver or newer.
  • <ver: any version older than ver, not including ver.
  • <=ver: version ver 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.

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, mocha
  • accent: rosewater, flamingo, pink, mauve, red, maroon, peach, yellow, green, teal, sky, sapphire, blue, lavender

For examples, visit Matrix Mode in the concepts section.

The filename key allows Whiskers to automatically write the output to a file.

The format used for rendering colors in hexadecimal can be customised with the hex_format frontmatter variable.

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 as a 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.tera
---
whiskers:
version: "^X.Y.Z"
hex_format: "0x{{B}}{{G}}{{R}}{{A}}"
---
{{red.hex}}

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:

example.tera
---
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}}"