{"_id":"lite-template","_rev":"5-843bc01f44a76ffe2076e468673680af","name":"lite-template","dist-tags":{"latest":"0.1.3"},"versions":{"0.0.1":{"name":"lite-template","version":"0.0.1","keywords":["ejs","template","engine","micro","lite","async","minimal","lightweight","typescript","javascript","nodejs","docmd"],"author":{"url":"https://mgks.dev","name":"Ghazi"},"license":"MIT","_id":"lite-template@0.0.1","maintainers":[{"name":"mgks","email":"hello@mgks.dev"}],"homepage":"https://docmd.io","bugs":{"url":"https://github.com/docmd-io/docmd/issues"},"dist":{"shasum":"aaef72fe7feedf4783cebc1c25a3c89ec509b718","tarball":"https://registry.npmjs.org/lite-template/-/lite-template-0.0.1.tgz","fileCount":9,"integrity":"sha512-QW1ZAqH+x8fL94+7HEYe2hW/aJKuQJqwnLxDwbmA+5e3GymQA37Rb8ct/T8OunfHTWf7Cte5nUY/hz58glELRw==","signatures":[{"sig":"MEUCICt1ISychdfc1ygIrI7S5PIZ02QCbEy6gRvVlxktcFHqAiEAvy3iSvCRLP0NqqdreUfo5d2QyIBLd8FoMBY/5gnJeaw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12755},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","funding":"https://github.com/sponsors/mgks","gitHead":"9c6158e9d227f430fedaa2f5a72021d7c9f6acbe","scripts":{"build":"tsc"},"_npmUser":{"name":"mgks","email":"hello@mgks.dev"},"repository":{"url":"git+https://github.com/docmd-io/docmd.git","type":"git","directory":"lite-template"},"_npmVersion":"11.10.0","description":"Ultra lightweight, zero-dependency async template engine compatible with basic EJS syntax.","directories":{},"_nodeVersion":"25.2.1","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/lite-template_0.0.1_1775326349626_0.6924156084640951","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"lite-template","version":"0.1.0","keywords":["ejs","template","engine","micro","lite","async","minimal","lightweight","typescript","javascript","nodejs","docmd"],"author":{"url":"https://mgks.dev","name":"Ghazi"},"license":"MIT","_id":"lite-template@0.1.0","maintainers":[{"name":"mgks","email":"hello@mgks.dev"}],"homepage":"https://docmd.io","bugs":{"url":"https://github.com/docmd-io/lite-template/issues"},"dist":{"shasum":"34b4c6abb3b8df177c616ca4e5ab94f3151f0e7c","tarball":"https://registry.npmjs.org/lite-template/-/lite-template-0.1.0.tgz","fileCount":5,"integrity":"sha512-bEqzlkC/i7wz2RU7SoDqho1l+QlFwZ6mtUMXjbkFCezfFfuOxDLizO5Gd8B4PsxpneF1yRuDUnA2Hc/FvcAU6w==","signatures":[{"sig":"MEQCHx11nfM6m41/AwxRTeq7Fi1+BhT7LR4tAD3n7tC6h3MCIQDIia8CupI8nmIbgQRONTXo+R/ZnEeCO3niYcpzf4uA9A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/lite-template@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":9406},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","funding":"https://github.com/sponsors/mgks","gitHead":"5ba4e1c1dac771b311ab66e4c5cca45bc006d780","scripts":{"build":"tsc"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:88bbe1f0-debd-4071-ba9a-c4cad1726c86"}},"repository":{"url":"git+https://github.com/docmd-io/lite-template.git","type":"git"},"_npmVersion":"11.12.1","description":"Ultra lightweight, zero-dependency async template engine compatible with basic EJS syntax.","directories":{},"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/lite-template_0.1.0_1775330937245_0.24853835765705168","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"lite-template","version":"0.1.1","keywords":["ejs","template","engine","micro","lite","async","minimal","lightweight","typescript","javascript","nodejs","docmd"],"author":{"url":"https://mgks.dev","name":"Ghazi"},"license":"MIT","_id":"lite-template@0.1.1","maintainers":[{"name":"mgks","email":"hello@mgks.dev"}],"homepage":"https://docmd.io","bugs":{"url":"https://github.com/docmd-io/lite-template/issues"},"dist":{"shasum":"5d6ed7df3cf840952680bc99aac7465be211250d","tarball":"https://registry.npmjs.org/lite-template/-/lite-template-0.1.1.tgz","fileCount":5,"integrity":"sha512-OsvZwKz6PS8vcEVE+YySnZSYeSx3fgpU3GzS+NpXjSM/54CiJ99QM+1Y7WU5I6e4argu21wCe86+++el71Qe5A==","signatures":[{"sig":"MEQCIBJ/NIW/IN1cQdBW/9DBwTuGsGTnB/pBN/rSl7u0NBOSAiBXzgTaMt9jk/6NW0xvRU5hBHfQoKfXcHlUdAF4oRag3w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/lite-template@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":14322},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","funding":"https://github.com/sponsors/mgks","gitHead":"155dbde1d217967788631079109880689d247a4e","scripts":{"build":"tsc"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:88bbe1f0-debd-4071-ba9a-c4cad1726c86"}},"repository":{"url":"git+https://github.com/docmd-io/lite-template.git","type":"git"},"_npmVersion":"11.12.1","description":"Ultra lightweight, zero-dependency async template engine compatible with basic EJS syntax.","directories":{},"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/node":"^25.5.2"},"_npmOperationalInternal":{"tmp":"tmp/lite-template_0.1.1_1775338961139_0.44670206725371986","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"lite-template","version":"0.1.2","keywords":["ejs","template","engine","micro","lite","async","minimal","lightweight","typescript","javascript","nodejs","docmd"],"author":{"url":"https://mgks.dev","name":"Ghazi"},"license":"MIT","_id":"lite-template@0.1.2","maintainers":[{"name":"mgks","email":"hello@mgks.dev"}],"homepage":"https://docmd.io","bugs":{"url":"https://github.com/docmd-io/lite-template/issues"},"dist":{"shasum":"3d67e484524b65f84111f23f830a40b20565e5d0","tarball":"https://registry.npmjs.org/lite-template/-/lite-template-0.1.2.tgz","fileCount":5,"integrity":"sha512-zWxWPs7QDGlHKOqgrSjYoq+zwQuvu+CUO6WkCRfnmme9pa8c0Mfv2huhoDfmbY7hUN5YTcuahD4SwI6/lww6jw==","signatures":[{"sig":"MEUCIAJA1yz7RuQgj/qXymyI4/nuOy1w9iBV1z0KlhKFRcNMAiEAxULBvhW1Z2eqdxhU0JTZ7zT1XOTzwCEUBoxQCvUMjw0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/lite-template@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":14460},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"funding":"https://github.com/sponsors/mgks","gitHead":"84da1a275e52e9ecd45ec0afa6c6b74892b9d505","scripts":{"build":"tsc"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:88bbe1f0-debd-4071-ba9a-c4cad1726c86"}},"repository":{"url":"git+https://github.com/docmd-io/lite-template.git","type":"git"},"_npmVersion":"11.12.1","description":"Ultra lightweight, zero-dependency async template engine compatible with basic EJS syntax.","directories":{},"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/node":"^25.5.2"},"_npmOperationalInternal":{"tmp":"tmp/lite-template_0.1.2_1775341041309_0.41497699795402654","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"lite-template","version":"0.1.3","description":"Ultra lightweight, zero-dependency async template engine compatible with basic EJS syntax.","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"build":"tsc","test":"npm run build >/dev/null && node --test"},"devDependencies":{"@types/node":"^26.1.2","typescript":"^7.0.2"},"keywords":["ejs","template","engine","micro","lite","async","minimal","lightweight","typescript","javascript","nodejs","docmd"],"author":{"name":"Ghazi","url":"https://mgks.dev"},"repository":{"type":"git","url":"git+https://github.com/docmd-io/lite-template.git"},"bugs":{"url":"https://github.com/docmd-io/lite-template/issues"},"homepage":"https://docmd.io","funding":"https://github.com/sponsors/mgks","license":"MIT","gitHead":"6d7ebce4f25aeba42a73b87aeb13b585faf95b29","_id":"lite-template@0.1.3","_nodeVersion":"24.18.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-JVN3BA0WMTjRshH1ljQd2ZF2019NhYpQgvi0VGLJ4TXc9kkfu6kx672DhUWPLlhFMfjZCirYY4emawXl3hEKPQ==","shasum":"f9b06554f62a603a849cbf55fb61060e7fdb69d6","tarball":"https://registry.npmjs.org/lite-template/-/lite-template-0.1.3.tgz","fileCount":5,"unpackedSize":14891,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/lite-template@0.1.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBk4ZoMzHs0f1Q0Uyp0/NgMLmLXfARkZHBWbGntYIFVqAiEAmixgTj44IAK7kXuMC1LnR05zY7oBGFcjFF+x9sFbSwc="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:88bbe1f0-debd-4071-ba9a-c4cad1726c86"}},"directories":{},"maintainers":[{"name":"mgks","email":"hello@mgks.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/lite-template_0.1.3_1785662819017_0.44488467468459847"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-04T18:12:29.565Z","modified":"2026-08-02T09:26:59.512Z","0.0.1":"2026-04-04T18:12:29.776Z","0.1.0":"2026-04-04T19:28:57.379Z","0.1.1":"2026-04-04T21:42:41.279Z","0.1.2":"2026-04-04T22:17:21.444Z","0.1.3":"2026-08-02T09:26:59.171Z"},"bugs":{"url":"https://github.com/docmd-io/lite-template/issues"},"author":{"name":"Ghazi","url":"https://mgks.dev"},"license":"MIT","homepage":"https://docmd.io","keywords":["ejs","template","engine","micro","lite","async","minimal","lightweight","typescript","javascript","nodejs","docmd"],"repository":{"type":"git","url":"git+https://github.com/docmd-io/lite-template.git"},"description":"Ultra lightweight, zero-dependency async template engine compatible with basic EJS syntax.","maintainers":[{"name":"mgks","email":"hello@mgks.dev"}],"readme":"# lite-template\n\n**High-Performance, Async-Safe JavaScript Template Engine.**\n\n`lite-template` is a modern, ultra-lightweight template engine designed for the needs of today's asynchronous web applications. It serves as a drop-in replacement for the aging, sync-heavy legacy of **EJS**, while introducing native, first-class support for `async/await` throughout the entire template lifecycle.\n\n## Technical Specifications\n\n- **Runtime**: Node.js (v18+), Browser (Modern), Cloudflare Workers.\n- **Language**: Core engine logic written in TypeScript.\n- **Compiler**: Direct-to-string AsyncFunction compilation.\n- **Distribution**: Native ESM (CommonJS not supported).\n\n## The Architecture: Async-First Compilation\n\nMost legacy engines (like `EJS`) were built in the pre-Promise era of Node.js. They execute template logic synchronously, which can block the event loop in high-throughput environments or when templates require database/API interaction.\n\n`lite-tpl` compiles logic directly into native, V8-optimized **`AsyncFunction`** objects. This enables seamless, non-blocking template execution that leverages existing JavaScript primitives for maximum efficiency.\n\n### Technical Limitations (Design Philosophy)\n\nTo prioritize performance and maintain its minimalist footprint (<10KB), `lite-template` purposefully omits several non-core EJS features:\n\n1.  **Strictly Logic-Driven**: Unlike EJS, it does not include a complex built-in caching layer. Reusable templates should be pre-compiled using `compile()` at the application level.\n2.  **Explicit Scope**: Uses the `with` block for performance. Variables must be defined within the provided `data` object to be accessible; it does not automatically pull from global scope.\n3.  **Include System**: A native `include()` function works out-of-the-box (just like EJS) when `options.filename` is provided to `render()`, managing recursive resolution automatically. Does not implement `<%- layout() %>` systems.\n4.  **No Middleware Integration**: This is a pure string-to-HTML engine—no native Express.js view-engine integration is included out of the box.\n5.  **ESM Only**: Built exclusively for modern ESM toolchains.\n\n\n*   **Async Native Engine**: Supports `await` natively within any `<% ... %>` or `<%= ... %>` block without messy workarounds.\n*   **Optimal Performance**: Compiles template strings directly into optimized JavaScript function strings, skipping the AST-processing overhead of heavier engines.\n*   **Predictable Scoping**: Leverages the JavaScript `with` scope for safe, predictable, and performant variable resolution.\n*   **Micro Footprint**: Under 10KB. Eliminates the hundreds of cascading dependencies common in larger engines.\n*   **Modern Compatibility**: Built for standard **EJS syntax** but engineered for the modern ES Module ecosystem.\n\n## Installation\n\n```bash\nnpm install lite-template\n```\n\n## Comparisons\n\n| Feature | EJS | lite-template |\n| :--- | :--- | :--- |\n| **Logic** | Sync-First | **Async-Native** |\n| **Parsing** | Bulky AST | **Direct-to-Function** |\n| **Weight (approx)** | ~50KB | **<10KB** |\n| **Dependencies** | Multiple (jake, async, etc.) | **Zero** |\n\n## Quick Start\n\n### Basic Rendering\n\n```javascript\nimport { render } from 'lite-tpl';\n\nconst template = `<h2>Hello, <%= name %></h2>`;\nconst html = await render(template, { name: \"System\" });\n```\n\n### Advanced Loops and Logic\n\n```javascript\nconst template = `\n  <div class=\"user-list\">\n    <% users.forEach(user => { %>\n      <div class=\"user-card\"><%= user.name %></div>\n    <% }); %>\n  </div>\n`;\n\nconst html = await render(template, {\n  users: [{ name: \"Alice\" }, { name: \"Bob\" }]\n});\n```\n\n### Native Built-in Includes\n\nWhen you pass `filename` in the options, `lite-template` automatically exposes a built-in cross-file `include()` resolver.\n\n```javascript\n// page.ejs\n// <h1>My Page</h1>\n// <%- await include('footer', { text: \"Copyright\" }) %>\n\nconst html = await render(\n  '<%- await include(\"footer\") %>', \n  { globalVar: true }, \n  { filename: '/path/to/page.ejs' }\n);\n```\n\n### First-Class Async/Await\n\n```javascript\nconst template = `\n  <div class=\"profile\">\n    <h2>User Details</h2>\n    <p>Age: <%= await getUserAge(id) %></p>\n  </div>\n`;\n\nconst html = await render(template, {\n  id: 101,\n  getUserAge: async (id) => `Verified Age for User #${id}`\n});\n```\n\n## API Reference\n\n### `render(template, data)`\n\n**Arguments:**\n- `template` (string): The raw template string to compile and evaluate.\n- `data` (object): The variable context to be accessible within the template.\n\n**Returns:**\n- `Promise<string>`: The final rendered output.\n\n### `compile(template)`\n\n**Arguments:**\n- `template` (string): The raw template string.\n\n**Returns:**\n- `(data) => Promise<string>`: A reusable, high-performance async render function.\n\n## Security Note\n\nLike EJS, `lite-template` compiles template logic into executable JavaScript and evaluates it against the provided `data`. Only render templates you control or that come from a trusted source. Never render untrusted, user-supplied template strings, exactly as you would not with EJS. The `<%= %>` tag escapes HTML output; use `<%- %>` only for values that are already known to be safe.\n\n## License\n\nMIT - Developed under the docmd ecosystem.\n","readmeFilename":"README.md"}