Skip to main content

Module render

Module render 

Source
Expand description

The renderer (docs/tooling/05_render.md): the form a module declares for an output with @render — a format and a layout, a template, a destination, a fan-out — read from the annotation (§3), the structured text of a document in that form (§4), and the templates (§5) and the fan-out (§6) that turn one evaluated root into text or files. The command line, the REPL, the library, and the editor preview all emit through here, so that the three implementations print the same bytes. A port of the reference’s render.ts.

Structs§

Context
what a template renders over (§5.4)
Delimiters
a template’s delimiters (§5.2): each an opener and a closer
Emission
what emits one root: its value, its form with the invocation’s overrides, and the template’s text when there is one
Form
the declared form of a root (§3): what @render says, every key optional
RenderError
a rendering diagnostic: the code, the message, and where — L:C of the tag, or a document path
Template
a parsed template: its path as given (diagnostics), its directory (includes), its nodes

Enums§

Emitted
the text a root is emitted as: one text, or the files of a fan-out (§6), path by path

Functions§

absolute
an absolute, normalized path (. and .. resolved), as the reference’s host resolves one
declared_form
the form @render declares on a declaration (§3), or the E7004 message naming what is wrong with it; a declaration without one is canonical JSON
emit_root
emit one root (§3.1): its structured text or its template’s text, as one text or one file per element
emit_root_to
Emit such a root to a writer without building its text whole; the bytes are emit_root’s.
emits_in_pieces
Whether a root’s text is the engine’s compact JSON and nothing else: no template, no fan-out, no layout pass, and a container, whose serialization always has text. Such a root can go to a file in pieces.
layout
the structured text of a document (read_json’s shape) in a format and layout (§4), one trailing newline
parse_template
parse a template’s text (§5.2–5.3); E7001 for what does not parse. path is the template’s path as given (its diagnostics name it); dir is where its includes resolve, the absolute directory it was read from
render_template
render a parsed template over a context (§5); a RenderError carries the diagnostic
resolve_in
dir/rel absolute and normalized (an absolute rel wins)
text_form
the text form of a value (§5.5); Err((code, message)) when it has none