Skip to content

Filters Reference

These are all of the filters available to use in your templates, alongside all of the existing Tera built-ins.

  • Description: Add a value to a color
  • Attributes
    • hue: i32 (degrees)
    • saturation: u8 (0–100)
    • lightness: u8 (0–100)
    • opacity: f32 (0.0–1.0)
  • Example: red | add(hue=30)ff6666
  • Description: Subtract a value from a color
  • Attributes
    • hue: i32 (degrees)
    • saturation: u8 (0–100)
    • lightness: u8 (0–100)
    • opacity: f32 (0.0–1.0)
  • Example: red | sub(hue=30)d30f9b
  • Description: Modify a color
  • Attributes
    • hue: i32 (degrees)
    • saturation: u8 (0–100)
    • lightness: u8 (0–100)
    • opacity: f32 (0.0–1.0)
  • Example: red | mod(lightness=80)f8a0b3
  • Description: Mix two colors together
  • Attributes
    • color
    • amount: f32 (0.0-1.0)
  • Example: red | mix(color=base, amount=0.5)e08097
  • Description: Serialize an object into a URL-safe string with LZMA compression
  • Example: some_object | urlencode_lzma"XQAAgAAEAAAAAAAAAABAqEggMAAAAA=="
  • Description: Truncate a number to a certain number of places
  • Example: 1.123456 | trunc(places=3)1.123
  • Description: Fetch a color’s hex representation. Shortcut for get(key="hex").
  • Example: red | hexd20f39
  • Description: Convert a color to an RGB CSS string
  • Example: red | css_rgbrgb(210, 15, 57)
  • Description: Convert a color to an RGBA CSS string
  • Example: red | css_rgbargba(210, 15, 57, 1.00)
  • Description: Convert a color to an HSL CSS string
  • Example: red | css_hslhsl(347, 87%, 44%)
  • Description: Convert a color to an HSLA CSS string
  • Example: red | css_hslahsla(347, 87%, 44%, 1.00)