ginger

Types

pub type Template {
  Template(content: String)
}

Constructors

  • Template(content: String)
pub type TemplateContext {
  TemplateContext(
    variables: dict.Dict(String, String),
    lists: dict.Dict(String, List(String)),
  )
}

Constructors

  • TemplateContext(
      variables: dict.Dict(String, String),
      lists: dict.Dict(String, List(String)),
    )
pub type TemplateEngine {
  TemplateEngine(
    template_dir: String,
    cache: dict.Dict(String, String),
  )
}

Constructors

  • TemplateEngine(
      template_dir: String,
      cache: dict.Dict(String, String),
    )
pub type TemplateError {
  IoError(String)
  RegexError(String)
}

Constructors

  • IoError(String)
  • RegexError(String)

Values

pub fn clear_cache(engine: TemplateEngine) -> TemplateEngine
pub fn context_from_list(
  variables: List(#(String, String)),
) -> TemplateContext
pub fn from_file(path: String) -> Result(Template, TemplateError)
pub fn from_string(content: String) -> Template
pub fn load_template_content(
  engine: TemplateEngine,
  name: String,
) -> Result(#(TemplateEngine, String), TemplateError)
pub fn new_context() -> TemplateContext
pub fn new_engine(template_dir: String) -> TemplateEngine
pub fn render(
  template: Template,
  context: dict.Dict(String, String),
) -> Result(String, TemplateError)
pub fn render_simple_template(
  engine: TemplateEngine,
  template_name: String,
  context: dict.Dict(String, String),
) -> Result(#(TemplateEngine, String), TemplateError)
pub fn render_template(
  engine: TemplateEngine,
  template_name: String,
  context: TemplateContext,
) -> Result(#(TemplateEngine, String), TemplateError)
pub fn render_with_loops(
  template: Template,
  context: TemplateContext,
) -> Result(String, TemplateError)
pub fn set_list(
  context: TemplateContext,
  key: String,
  items: List(String),
) -> TemplateContext
pub fn set_variable(
  context: TemplateContext,
  key: String,
  value: String,
) -> TemplateContext
Search Document