RustQ.Template (rustq v1.0.0-rc.19)

Copy Markdown View Source

Parsed Rust template plus pending substitutions.

Summary

Functions

Replaces each __rq_include!("path") marker with the file it names, relative to :include_dir or the template's directory, rejecting include cycles.

Expands __rq_include! markers when the :include_dir option is given.

Formats rendered code with rustfmt, or the command the :rustfmt option names.

Turns native template errors into maps with atom fields, tagged with the template's file.

Prepends the :preamble option to rendered code.

Types

t()

@type t() :: %RustQ.Template{
  bindings: keyword(),
  filename: String.t(),
  source: String.t(),
  splices: [{atom(), term()}]
}

Functions

expand_includes(source, filename, opts)

Replaces each __rq_include!("path") marker with the file it names, relative to :include_dir or the template's directory, rejecting include cycles.

maybe_expand_includes(source, filename, opts)

Expands __rq_include! markers when the :include_dir option is given.

maybe_rustfmt(code, opts, filename)

Formats rendered code with rustfmt, or the command the :rustfmt option names.

normalize_errors(errors, filename)

Turns native template errors into maps with atom fields, tagged with the template's file.

with_preamble(code, opts)

Prepends the :preamble option to rendered code.