{"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.4.0","deps":[],"features":{},"cksum":"sha256:0940f625fc656f87270e76ea6b4b9f25974862c6ba9598600f6870efa7cc616f","sig":"ed25519:be111f398658dc3e88ac020e0ff26d22371b0a896002ec6666bd9063834e562f91dade7e4f2cc0d7808fc919073f5d64879bf90c8eedb16c6eec9bc663911a06","key_fp":"SHA256:xl0hCTnhRoxLob4M6UdsT7Jtjn0a2wyYJf9ObIANTao","yanked":false,"edition":"2026","hew":">=0.6.1, <0.7.0","registry_sig":"ed25519:ea88c207a5c0557f3fb4776a3e0b18348b0bc7b9ccf159133b55564ea4f356460ffac689538901ee4df3a5166faf5ff12cbbccc35fe390a2c99c5f9b65bbbe07","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-21T03:48:00.732Z","dl":"https://cdn.hewpkg.com/tarballs/hew/template/0.4.0.tar.zst"}}