Skip to content

Functions Reference

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

  • Description: Return one value if a condition is true, and another if it’s false.
  • Example: if(cond=true, t=1, f=0) ⇒ 1
  • Description: Create an object from the input.
  • Example: object(a=1, b=2) ⇒ {a: 1, b: 2}
  • Description: Convert a color to an RGB CSS string.
  • Example: css_rgb(color=red) ⇒ rgb(210, 15, 57)
  • Description: Convert a color to an RGBA CSS string.
  • Example: css_rgba(color=red) ⇒ rgba(210, 15, 57, 1.00)
  • Description: Convert a color to an HSL CSS string.
  • Example: css_hsl(color=red) ⇒ hsl(347, 87%, 44%)
  • Description: Convert a color to an HSLA CSS string.
  • Example: css_hsla(color=red) ⇒ hsla(347, 87%, 44%, 1.00)
  • Description: Read and include the contents of a file, path is relative to the template file.
  • Example: read_file(path="abc.txt") ⇒ abc