Templates

Basic Syntax

Type Syntax Description
Expression (Keyword) {{ expression }} Evaluates and outputs a value.
Block <* ... *> Used for loops, conditionals and includes.
Escaping \{{ ... }} Escapes template output so it isn't evaluated.

Colors and variables

You can use your own colors by importing JSON or using the to_color filter.

Color formats

Name Format Output
hex #RRGGBB #470228
hex_stripped RRGGBB 470228
hex_alpha #RRGGBBAA #470228ff
hex_alpha_stripped RRGGBBAA 470228ff
alpha_hex #AARRGGBB #ff470228
alpha_hex_stripped AARRGGBB ff470228
rgb rgb(r, g, b) rgb(71, 2, 40)
rgba rgba(r, g, b, a) rgba(71, 2, 40, 1.0)
hsl hsl(h, s, l) hsl(332.2, 94.5%, 14.3%)
hsla hsla(h, s, l, a) hsla(332.2, 94.5%, 14.3%, 1.0)
red red (0 - 255) 71
green green (0 - 255) 2
blue blue (0 - 255) 34
alpha alpha (0.0 - 1.0) 0.7
hue hue (0.0 - 360.0) 332.2
saturation saturation (0.0 - 100.0) 94.5%
lightness lightness (0.0 - 100.0) 14.3%

Material Design 3

Material Design 3 (MD3) colors focus on personalized, accessible, and dynamic schemes, using 5 key roles—Primary, Secondary, Tertiary, Neutral, and Neutral Variant.

Usage:

{{ colors.<name>.<mode>.<format>}}

Example:

{{ colors.primary.default.hex }}

Name Description
primary Main brand color
on_primary Text/Icons on top of primary
primary_container Subtle background for primary elements
on_primary_container Text on top of primary container
inverse_primary Primary color for opposite theme
secondary Less prominent accent color
on_secondary Text/Icons on top of secondary
secondary_container Subtle background for secondary elements
on_secondary_container Text on top of secondary container
tertiary Contrasting accent color for balance
on_tertiary Text/Icons on top of tertiary
tertiary_container Subtle background for tertiary elements
on_tertiary_container Text on top of tertiary container
error Color used for errors/warnings
on_error Text/Icons on top of error color
surface Main background for components (cards, sheets)
on_surface Primary text color on surfaces
surface_variant Secondary background for components
on_surface_variant Secondary text color on surfaces
outline Color for borders and dividers
outline_variant Subtle divider/border color
background The absolute background of the app/screen
on_background Text on the main background
shadow Color used for elevation shadows
scrim Overlay color for modal backdrops

Base16

Base16 is a framework for creating consistent, syntax-highlighting color themes across various applications (terminal, editor, shell) using a standardized palette of 16 colors. It consists of 8 shades (for background/foreground) and 8 accent colors, ensuring high contrast, readability, and a unified look across different software.

Usage:

{{ base16.<name>.<mode>.<format>}}

Example:

{{ base16.base00.default.hex }}

Name Description
base00 Default Background
base01 Lighter Background (Status bars)
base02 Selection Background
base03 Comments, Invisibles
base04 Dark Foreground (Used for status bars)
base05 Default Foreground, Caret, Delimiters
base06 Light Foreground
base07 Light Background
base08 Variables, XML Tags, Red
base09 Integers, Boolean, Constants, Orange
base0a Classes, Strings, Functions, Yellow
base0b Strings, Inherited Class, Green
base0c Support, Regex, Escape Characters, Cyan
base0d Functions, Methods, Attribute IDs, Blue
base0e Keywords, Storage, Selector, Magenta
base0f Deprecated, Opening/Closing Embedded Tags, Brown

Variables

Name Description
is_dark_mode Is true if dark mode is enabled.
mode Dark or Light depending on the mode.
scheme Will resolve to the current scheme chosen.

Expressions

Use dot notation to access nested values inside context objects.

{{ colors.primary.default.hex }}
{{ palettes.error._99.hex }}
{{ mode }}

Example:

{{ custom.red_color.hex }} -> #470228
{{ custom.red_color.rgb }} -> rgb(255, 0, 0)

In JSON:

{
  "custom": {
    "red_color": {
      "color": "#470228"
    }
  }
}

Includes

Includes another template file, the name should be the template name you put in the config.

If you just want to use the included template inside of another one and don't want to write it to a file, you can just comment out the output_path

If you set a custom scheme type for the main template, the included template will follow it.

[templates.includeme]
input_path = "./include.txt"
# The output path is optional if you just want to import the template
# output_path = "./a/include.txt"

Example:

<* include "includeme" *>

Conditionals

Conditionals allow branching logic inside templates.

Negation with the not keyword is supported for any version above v3.1.0

<* if {{ condition }} *>
  ...content if true...
<* else *>
  ...content if false...
<* endif *>

If statement

<* if {{ is_dark_mode }} *>
  Dark Mode
<* else *>
  Light Mode
<* endif *>

If statement using negation

<* if not {{ condition }} *>
  ...content if false...
<* else *>
  ...content if true...
<* endif *>

Loops

Range Loop

Iterates over a numeric range (inclusive).

<* for i in -10..10 *>
  {{ i }}
<* endfor *>

Key-Value Loop

Iterates through maps or objects, exposing both key and value bindings.

Listing all the MD3 colors

<* for name, value in colors *>
  {{ name }}: {{ value.default.hex }};
<* endfor *>

Filters

Filters transform or modify values, they are chained using the pipe symbol (|). They can support Expressions as arguments.

Example:

{{ colors.primary.default.hex | lighten: 20.0 | invert }}

<* for i in -10..10 *>
    actual: {{ i }} multiplied: {{ {{ i }} * 10 }} {{ colors.red.default.hex | lighten: {{i}} * 10 }}
<* endfor *>

Arithmetic and Nested Expressions

Expressions can be nested or contain arithmetic operations.

{{ {{ i }} * 10 }}
{{ colors.red.default.hex | lighten: {{ i }} * 10 }}

Escaping Output

To render raw {{ ... }} text without evaluating it:

\{{ colors.primary.default.hex }}

This will output literally {{ colors.primary.default.hex }} in the result.