himeno/mopress/template does not have a README file

    Context

    type Context = Map[String, Value]

    A named set of template variables, as passed to apply_template / apply_template_strict.

    Template

    type Template = Array[TemplateNode]

    A parsed template, as produced by parse_template.

    TemplateParseError

    pub suberror TemplateParseError {
    TemplateParseError(String)
    } derive(Eq,
    Debug
    )

    Error raised when a template's source cannot be parsed into a valid template AST. The associated String carries a human-readable description of the parse failure.

    TemplateParseError::equal

    TemplateParseError::not_equal

    TemplateParseError::output

    fn TemplateParseError::output(self : TemplateParseError, logger : &Logger) -> Unit

    TemplateParseError::to_string

    fn TemplateParseError::to_string(self : TemplateParseError) -> String

    TemplateRenderError

    pub suberror TemplateRenderError {
    UndefinedVariableError(String)
    NonArrayForLoopError(String)
    PartialLoadError(String)
    PartialParseError(String)
    RecursivePartialError(String)
    } derive(Eq,
    Debug
    )

    Errors that can occur while rendering a parsed template against a variable context, as raised by apply_template_strict.

    TemplateRenderError::equal

    TemplateRenderError::not_equal

    TemplateRenderError::output

    fn TemplateRenderError::output(self : TemplateRenderError, logger : &Logger) -> Unit

    TemplateRenderError::to_string

    fn TemplateRenderError::to_string(self : TemplateRenderError) -> String

    TemplateNode

    pub(all) enum TemplateNode {
    Text(String)
    Variable(String)
    If(String, Array[TemplateNode], Array[TemplateNode])
    For(String, Array[TemplateNode])
    Partial(String, Array[(String, String)])
    } derive(Eq,
    Debug
    )

    A single node in a parsed template's AST.

    TemplateNode::equal

    TemplateNode::not_equal

    fn TemplateNode::not_equal(x : TemplateNode, y : TemplateNode) -> Bool

    Value

    pub(all) enum Value {
    String(String)
    Number(Double)
    Bool(Bool)
    Array(Array[Value])
    Object(Map[String, Value])
    } derive(Eq,
    Debug
    )

    A dynamically-typed value available to templates as part of their rendering context.
    impl Show for Value

    Value::equal

    fn Value::equal(Value, Value) -> Bool

    Value::from_json

    Converts a Json value into its corresponding Value representation, e.g. for constructing template variables from JSON data (see Summary::flatten).

    Value::not_equal

    fn Value::not_equal(x : Value, y : Value) -> Bool

    Value::output

    fn Value::output(self : Value, logger : &Logger) -> Unit

    Value::to_repr

    Value::to_string

    fn Value::to_string(self : Value) -> String

    apply_template

    fn apply_template(template : Array[TemplateNode], context : Map[String, Value]) -> String

    Renders a parsed template against the given variable context, producing the final output string.

    Rendering errors (e.g. an undefined variable reference, or a failed partial) are tolerated on a per-node basis: the offending template node is simply rendered as empty output, and rendering continues for the rest of the template, rather than the whole render failing. Use apply_template_strict if such errors should instead abort rendering entirely.

    apply_template_strict

    fn apply_template_strict(template : Array[TemplateNode], context : Map[String, Value]) -> String raise TemplateRenderError

    Like apply_template, but raises TemplateRenderError as soon as any node fails to render — e.g. an undefined variable, a non-array value used in a for loop, or a problem loading/parsing a referenced partial — instead of tolerating the failure by rendering that node as empty output.

    parse_template

    fn[T : Show] parse_template(input : T) -> Array[TemplateNode] raise TemplateParseError

    Parses input (any Show-able value, typically a String of raw template source) into a template AST.

    Raises TemplateParseError if input is not valid template syntax.

    with_render_counter

    async fn[T] with_render_counter(counter :
    Ref
    [Int], f : async () -> T) -> T

    Source Files