tagg

Functions

pub fn default_component_func(
  tagg: Tagg,
  doc_section: Section,
  context: Context,
) -> Result(List(Section), TaggError)

This is a pass-through function that can serve as a component’s transformation function. This can be used if you want to have a custom component (tag name) that does not have any custom logic.

pub fn get_html(
  children: List(Section),
  context: Context,
  tagg: Tagg,
) -> Result(String, TaggError)

Transforms a list of Tag/Text sections into an HTML string.

pub fn get_html_rec(
  sections: List(Section),
  tagg: Tagg,
  acc: String,
) -> Result(String, TaggError)

Recursive function to get the output HTML, given a list of Tag/Text sections.

pub fn render(
  tagg: Tagg,
  filepath: String,
  context: Context,
) -> Result(String, TaggError)

Renders a template file to an HTML string, using the provided context. The context is a data structure that allows the consumer to pass in dynamic values (e.g. a list of employee records from a database) to populate the template.

pub fn replace_text_vars(
  s: String,
  context: Context,
  acc: String,
) -> String

Find template variables (e.g. @employee.first_name) in the HTML string and replace them with the values in the context, if they exist. If they don’t exist, then leave the variable intact in the output HTML.

Search Document