
gracile-core
The engine at the heart of Gracile. Contains the lexer, parser, AST, and renderer. Use this crate directly if you want to embed the engine into your own library or framework without the re-export layer.
[]
= "0.1"
use ;
let engine = new
.with_strict
.register_filter;
let ctx = context! ;
let output = engine.render?;
// → "HELLO WORLD!!!"
Syntax at a glance
| Syntax | Description |
|---|---|
{= expr } |
Interpolate (HTML-escaped) |
{~ expr } |
Interpolate raw HTML (unescaped) |
{! comment !} |
Comment, stripped from output |
{#if cond} … {:else} … {/if} |
Conditional |
{#each items as item, i} … {:else} … {/each} |
Loop with optional index |
{#each items as item, i, loop} … {/each} |
Loop with metadata (loop.index, .length, .first, .last) |
{#snippet name(params)} … {/snippet} |
Define a reusable snippet |
{@render name(args)} |
Render a snippet |
{@include "name"} |
Inline a pre-registered template |
{@const name = expr} |
Local binding |
{#raw} … {/raw} |
Verbatim block, no parsing |
{\= / {\~ |
Escape: emit a literal {= / {~ |
Most users should depend on the gracile crate instead, which re-exports this crate's public API under a cleaner name.