Module
tuck/render
src/tuck/render.pookaWalking a template with the data in hand, and writing as it goes.
Values are looked up in the loop variables first, then in the data.
A name that is not there is not an error straight away: {% if %} reads
it as false and | default replaces it. Only printing it, looping over
it or filtering it is an error, and then the message says what was
missing and what was there instead.
API reference
class Val
A value while it is being worked out.
class Found(value: Json) is Val
A value from the template or the data.
value: Json
$package/pooka_json/pooka/json.Json
fn($package/pooka_json/pooka/json.Json) -> tuck/render.Foundclass Safe(text: String) is Val
Text that is already safe to print without escaping.
text: String
String
fn(String) -> tuck/render.Safeclass Missing(message: String, at: Pos) is Val
Something that is not there: the sentence to say if it matters, and where in the template it was asked for.
message: String
Stringat: Pos
tuck/error.Pos
fn(String, tuck/error.Pos) -> tuck/render.Missingclass Version(owner: String, body: List(Node))
Everything rendering needs to know besides the nodes themselves.
owner: String
Stringbody: List(Node)
List(tuck/ast.Node)
fn(String, List(tuck/ast.Node)) -> tuck/render.Versionclass Scope(
template: String,
load: fn(String) -> Result(Document, TuckError),
filters: List(#(String, Filter)),
functions: List(#(String, Function)),
escape: Bool,
frames: List(List(#(String, Val))),
data: List(#(String, Json)),
blocks: List(#(String, List(Version))),
stack: List(String),
parents: List(Version)
)
template: String
Stringload: fn(String) -> Result(Document, TuckError)
fn(String) -> Result(tuck/ast.Document, tuck/error.TuckError)filters: List(#(String, Filter))
List(#(String, tuck/filter.Filter))functions: List(#(String, Function))
List(#(String, tuck/function.Function))escape: Bool
Boolframes: List(List(#(String, Val)))
List(List(#(String, tuck/render.Val)))data: List(#(String, Json))
List(#(String, $package/pooka_json/pooka/json.Json))blocks: List(#(String, List(Version)))
List(#(String, List(tuck/render.Version)))stack: List(String)
List(String)parents: List(Version)
List(tuck/render.Version)
fn(String, fn(String) -> Result(tuck/ast.Document, tuck/error.TuckError), List(#(String, tuck/filter.Filter)), List(#(String, tuck/function.Function)), Bool, List(List(#(String, tuck/render.Val))), List(#(String, $package/pooka_json/pooka/json.Json)), List(#(String, List(tuck/render.Version))), List(String), List(tuck/render.Version)) -> tuck/render.Scopedocument(
name: String,
load: fn(String) -> Result(Document, TuckError),
filters: List(#(String, Filter)),
functions: List(#(String, Function)),
escape: Bool,
data: List(#(String, Json))
) -> Result(String, TuckError)
fn(String, fn(String) -> Result(tuck/ast.Document, tuck/error.TuckError), List(#(String, tuck/filter.Filter)), List(#(String, tuck/function.Function)), Bool, List(#(String, $package/pooka_json/pooka/json.Json))) -> Result(String, tuck/error.TuckError)Render the template called name, with data as its values.
load finds a template's document by name, for this template and for
anything it includes or extends. escape makes every printed value safe
for HTML.