{"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","deps":[],"features":{},"cksum":"sha256:cc8f4f04481377c73a244a28d726958b1574e3b9270a113be29746ecc60117a1","sig":"ed25519:6dbada2ff5368b8a0c3655c9816b012a946cab9cd73f2e77fefbeda4c77cd6d3e90a88b854ebb71bd1da48806acacd1aa911fd5a49f911f4c7b1ab1b2ff76a05","key_fp":"SHA256:QDgYk38yt+UbTDqWpi+aVd+Vkirhyd7m4y+5bVuNIpg","yanked":false,"edition":"2026","hew":">=0.10.0, <0.12.0","registry_sig":"ed25519:4f26ff323cf7f188323452994d83191a73d7e4e250204415c99a0990958e67c72cf05a1a260235d310850df8112b306dba7326ac930db090463420f0ceffdd04","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-11-13T06:01:29.581Z","dl":"https://cdn.hewpkg.com/tarballs/hew/template/0.7.0.tar.zst"}}