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
object
Section titled “object”- Description: Create an object from the input.
- Example:
object(a=1, b=2)
⇒{a: 1, b: 2}
css_rgb
Section titled “css_rgb”- Description: Convert a color to an RGB CSS string.
- Example:
css_rgb(color=red)
⇒rgb(210, 15, 57)
css_rgba
Section titled “css_rgba”- Description: Convert a color to an RGBA CSS string.
- Example:
css_rgba(color=red)
⇒rgba(210, 15, 57, 1.00)
css_hsl
Section titled “css_hsl”- Description: Convert a color to an HSL CSS string.
- Example:
css_hsl(color=red)
⇒hsl(347, 87%, 44%)
css_hsla
Section titled “css_hsla”- Description: Convert a color to an HSLA CSS string.
- Example:
css_hsla(color=red)
⇒hsla(347, 87%, 44%, 1.00)
read_file
Section titled “read_file”- Description: Read and include the contents of a file, path is relative to the template file.
- Example:
read_file(path="abc.txt")
⇒abc