Module: reefmarker.engine
Source: ./reefmarker/engine.reef
Overview
reefmarker/engine — public FTL render API.
parse + render / render_string / render_template for text, ${} interpolations, if / list / assign / include / noparse, macro / attempt / switch / stop / return. Other node kinds are unexpected. create() uses FileLoader(cfg.template_dir). The node walk uses an internal RenderStatus (Ok / Err / Stop / Return); Stop and a top-level Return become Ok(buffer). Include and macro calls share a nesting cap of 32; exceeding it is Err(InvalidInput).
Usage: import reefmarker.engine as reefmarker let eng = reefmarker.create(reefmarker.Config { template_dir: ".", cache: false, auto_reload: false }) let r = reefmarker.render(eng, "hello.ftl", root)
Types
Config
Fields:
| Name | Type |
|---|---|
template_dir |
string |
cache |
bool |
auto_reload |
bool |
Engine
Fields:
| Name | Type |
|---|---|
cfg |
Config |
loader |
loader.Loader |
cache_map |
hashmap.HashMap[string, Template] |
Template
Fields:
| Name | Type |
|---|---|
name |
string |
source |
string |
nodes |
[ast.Node] |
mtime |
int64 |
RenderStatus (enum)
Variants:
OkErrStopReturn
WalkResult
Fields:
| Name | Type |
|---|---|
status |
RenderStatus |
err |
error.Error |
Functions
fn create(cfg: Config): Engine
fn create_with_loader(cfg: Config, ldr: loader.Loader): Engine
fn parse(src: string): result.Result[Template, error.Error]
fn dummy_err(): error.Error
fn walk_ok(): WalkResult
fn walk_err(e: error.Error): WalkResult
fn walk_stop(): WalkResult
fn walk_return(): WalkResult
fn walk_is_ok(w: WalkResult): bool
fn walk_fail(span: source.SourcePos, msg: string): WalkResult
fn is_null_literal(e: ast.Expression): bool
fn eval_interp(node: ast.Node, ctx: context.Context): result.Result[value.Value, error.Error]
fn render_if(engine: Engine, node: ast.Node, ctx: context.Context, b: sb.StringBuilder, depth: int): WalkResult
fn render_list(engine: Engine, node: ast.Node, ctx: context.Context, b: sb.StringBuilder, depth: int): WalkResult
fn render_assign(engine: Engine, node: ast.Node, ctx: context.Context, depth: int): WalkResult
fn render_include(engine: Engine, node: ast.Node, ctx: context.Context, b: sb.StringBuilder, depth: int): WalkResult
fn render_attempt(engine: Engine, node: ast.Node, ctx: context.Context, b: sb.StringBuilder, depth: int): WalkResult
fn render_switch(engine: Engine, node: ast.Node, ctx: context.Context, b: sb.StringBuilder, depth: int): WalkResult
fn render_macro_call(engine: Engine, node: ast.Node, ctx: context.Context, b: sb.StringBuilder, depth: int): WalkResult
fn render_node(engine: Engine, node: ast.Node, ctx: context.Context, b: sb.StringBuilder, depth: int): WalkResult
fn render_nodes(engine: Engine, nodes: [ast.Node], ctx: context.Context, b: sb.StringBuilder, depth: int): WalkResult
fn lookup_mtime(engine: Engine, name: string): int64
fn load_template(engine: Engine, name: string): result.Result[Template, error.Error]
fn render_template(engine: Engine, template: Template, root: hashmap.HashMap[string, value.Value]): result.Result[string, error.Error]
fn render(engine: Engine, name: string, root: hashmap.HashMap[string, value.Value]): result.Result[string, error.Error]
fn render_string(engine: Engine, src: string, root: hashmap.HashMap[string, value.Value]): result.Result[string, error.Error]
Procedures
proc cache_store(engine: Engine, name: string, t: Template)
Generated by reefc doc