Skip to content

stdlib/templateView source ↗

template

8 items · generated by scribe fromstdlib/template.fd· synced 2026-11-15

stdlib/template8 items

Contents

template_parse

Parse a template string into a Template struct. Extracts {{variable}} and {{variable|filter}} parts. Everything else is treated as literal text.

pub fn template_parse(source: str) -> Template {

Parameters:

  • source: str

Returns: Template

Defined at line 47


template_render

Render a template with a JSON data context. The data context is a JSON object string (e.g. {“name”:“Alice”,“age”:30}). Variables in the template are looked up by name in the JSON object.

pub fn template_render(tmpl: Template, data: str) -> str {

Parameters:

  • tmpl: Template
  • data: str

Returns: str

Defined at line 125


apply_filter

Apply a filter to a value. Supported filters: upper, lower, trim, default

pub fn apply_filter(value: str, filter: str) -> str {

Parameters:

  • value: str
  • filter: str

Returns: str

Defined at line 152


render

Convenience: parse and render a template in one call.

pub fn render(source: str, data: str) -> str {

Parameters:

  • source: str
  • data: str

Returns: str

Defined at line 173


render_file

Render a template from a file. Reads the file, parses it, and renders with the given data context.

pub fn render_file(path: str, data: str) -> str {

Parameters:

  • path: str
  • data: str

Returns: str

Defined at line 180


comptime_template

Comptime template placeholder — when comptime gen is available, this will be replaced by a comptime function that generates a typed rendering function from the template source.

pub fn comptime_template(source: str) -> Template {

Parameters:

  • source: str

Returns: Template

Defined at line 203


Generated by scribe, the Fides documentation generator