{"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.2.0","deps":[],"features":{},"cksum":"sha256:26b75c610c639c62073dd5ef51ebfd35d36b9abb21aa6713a42f72bea8f65f89","sig":"ed25519:d3ea6ce3dfa53c1c30114e6d961cf2515ec843b342af50b6f424d9ebd941468c4f970af9f4e86ac163ed3078e8bd9b81ec7b683431dadbbb4227e75eabe94e08","key_fp":"SHA256:nzUYL3OflVsrmx8SM+vXLmUdfWPGmB649WfSHkWW09M","yanked":false,"edition":"2026","hew":">=0.6.0-rc1, <0.7.0","registry_sig":"ed25519:fb9cab8b3cdb160ad5f7ff998a06edc29d58346dc06f77bc060cd7093863c556480b02a071f0b2fec0ed0311f89c5b789469d027c344a9d1da0e4b8f5e69cc01","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-08-15T04:28:15.732Z","dl":"https://cdn.hewpkg.com/tarballs/hew/template/0.2.0.tar.zst"}}