Expand description
Tera template functions for data loading and content rendering
Functions§
- highlight_
filter - highlight filter - Syntax highlight code with a specified language Usage: {{ code | highlight(lang=“python”) }}
- html_
to_ text_ filter - html_to_text filter - Convert HTML to beautifully formatted plain text
- linebreaks_
filter - linebreaks filter - Convert newlines to
tags and double newlines to paragraphs Also supports basic markdown: bold, label,code - make_
asset_ filter - Create the asset filter that looks up hashed paths from the manifest Usage: {{ “/styles/main.css” | asset }} Returns the hashed path if found, otherwise returns the original path
- make_
list_ dirs - list_dirs(path) - List subdirectories Returns array of directory names (strings)
- make_
list_ files - list_files(path, pattern?) - List files with metadata Returns array of objects: [{path, name, stem, ext}, …] Optional pattern argument supports glob syntax (e.g., “solution.”, “.py”)
- make_
load_ json - load_json(path) - Load and parse a JSON file Returns the parsed JSON value, or Null if file doesn’t exist or is invalid
- make_
read_ file - read_file(path) - Read a file as text Returns the file content as string, or Null if file doesn’t exist
- make_
read_ markdown - read_markdown(path) - Read a Markdown file and return as HTML Returns the rendered HTML as string, or Null if file doesn’t exist
- markdown_
filter - markdown filter - Convert markdown text to HTML
- register_
data_ functions - Register all data functions with Tera