{"metadata":{"name":"hew/template","vers":"0.7.0","description":"Mustache-lite HTML templating for Hew — safe interpolation with automatic HTML escaping","license":"MIT OR Apache-2.0","authors":["Hew Contributors"],"deps":[],"features":{},"keywords":["template","html","mustache","escaping","web"],"repository":"https://github.com/hew-lang/ecosystem","edition":"2026","hew":">=0.10.0, <0.12.0","readme":"# hew.template\n\n`hew.template` renders small Mustache-style HTML templates. Double-brace\nplaceholders escape HTML metacharacters; triple-brace placeholders insert\ntrusted, pre-rendered HTML unchanged.\n\nThe checked [render page example](examples/render_page.hew) is below; its\ntest pins the rendered page, so `hew test template` fails if the output\nchanges:\n\n```hew\nimport hew.template;\n\nfn render_page() -> string {\n    let context = \"name\\n<Ada & Co>\\nbody\\n<strong>Welcome</strong>\";\n    template.render(\"<h1>Hello, {{name}}!</h1><main>{{{body}}}</main>\", context)\n}\n\nfn main() {\n    println(render_page());\n}\n\n#[test]\nfn escapes_the_name_and_keeps_the_trusted_body() {\n    assert(render_page() == \"<h1>Hello, &lt;Ada &amp; Co&gt;!</h1><main><strong>Welcome</strong></main>\");\n}\n```\n\nRun it from the ecosystem checkout:\n\n```sh\nhew run --pkg-path . template/examples/render_page.hew\n```\n\nThe program prints:\n\n```html\n<h1>Hello, &lt;Ada &amp; Co&gt;!</h1><main><strong>Welcome</strong></main>\n```\n\nContext is a newline-delimited sequence of key/value pairs. An unpaired key\nhas an empty value, duplicate keys use the last value, and an unknown\nplaceholder renders as empty text. Only LF (`\\n`) separates fields; a CR\n(`\\r`), including the CR in a CRLF pair, remains part of its key or value.\n\nMarker parsing commits to the longest opening marker. `{{{` therefore starts\na raw placeholder and must be closed by `}}}`. If its exact closing marker is\nmissing, the malformed marker and the rest of the template render literally;\nthe renderer does not retry at the second `{`. A valid double-brace marker\nfollowed by an extra `}` renders its escaped value and preserves that extra\nbrace. A malformed raw marker is never reinterpreted as an escaped marker one\nbyte later: a template that opens `{{{` and never closes it renders literally\nrather than silently changing meaning.\n\nA lone `{{` or a lone `}}` has no matching marker and renders literally.\n\nRendering scans the context and template once, uses average constant-time\ncontext lookup, and appends rendered UTF-8 into a growable buffer. Expected\ntime is linear in the context, template, and rendered output sizes. Use raw\ntriple-brace placeholders only for HTML you already trust.\n"},"version":{"name":"hew/template","vers":"0.7.0-rc1","deps":[],"features":{},"cksum":"sha256:647902ef3157ec018fe2f7c51c0755573532eaee58e812b30f147dc29916d05c","sig":"ed25519:4e27d0549d565039cea4a89cfe4673190d589d6030fb21aa4627249e9f1a0ad42e100058d0529ba5d1c865eea3f12bb95a4e94006133a481f105d25f753b030b","key_fp":"SHA256:eJ/AxFqPuRnxO+ddzX7ZfpfHcRs/3Dh4c81uBJi9tfM","yanked":false,"edition":"2026","hew":">=0.10.0, <0.11.0","registry_sig":"ed25519:9eed1cedd579ee00c3bdce4522e7743659c13e0c3ad19107752793a95fab4e7293219ea3d54764fd5eb5da0d9ab537caced1580051df1ec50a2c8363383b1705","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-26T17:17:11.860Z","dl":"https://cdn.hewpkg.com/tarballs/hew/template/0.7.0-rc1.tar.zst"}}