March Docs

Forge.Lower

Forge.Lower — bastion lower CLI subcommand.

Lowers .march.html template files to .march modules with ~H sigils.

Usage: forge bastion.lower <input.march.html> <output.march> <output.march.spans>

The lowering pass:

  1. Extracts the --- frontmatter block (fn signature + use declarations)
  2. Parses the template body into tokens (literal HTML, {expr}, {#if}, etc.)
  3. Resolves <.Component /> calls to module-qualified function calls
  4. Assembles <:slot> blocks into IOList arguments
  5. Emits a .march module wrapping the body in ~H"""..."""
  6. Writes a .march.spans sidecar for source-map error reporting

The generated .march file is a build artifact — never committed.

Types

typeTokenToken =#
typeAttrAttr = Attr(String, AttrValue)#
typeAttrValueAttrValue =#
typeFrontmatterFrontmatter = Frontmatter(Option(String), List(String))#
typeSpanEntrySpanEntry = SpanEntry(Int, Int, Int, String)#

Functions

fnlowerlower(content : String, input_path : String) : (String, String)#

Lower a .march.html template file to a .march module source string.

Returns a tuple of (march_source, spans_table).

  let (source, spans) = Forge.Lower.lower(content, "src/my_app/templates/home.march.html")
fnlower_filelower_file(input_path : String, output_march : String, output_spans : String) : Result(String, String)#

Lower a .march.html file and write the output files.

Reads input_path, writes output_march and output_spans.

fnmainmain(_cap_fileread : Cap(IO.FileRead), _cap_filewrite : Cap(IO.FileWrite), _cap_process : Cap(IO.Process), _cap_console : Cap(IO.Console))#
fnrunrun(args)#