{"id":29623174,"url":"https://github.com/beingsuz/uwu-template","last_synced_at":"2026-04-11T01:57:32.507Z","repository":{"id":54574192,"uuid":"495187372","full_name":"beingsuz/uwu-template","owner":"beingsuz","description":"⚡ Blazingly fast template engine for Deno/JS - 6x faster than Handlebars, 1.5x faster than Pug. Features Handlebars-like syntax, block helpers with options, layouts, and compile-time optimization. Battle-tested performance.","archived":false,"fork":false,"pushed_at":"2025-06-20T18:17:30.000Z","size":1895,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T07:18:46.432Z","etag":null,"topics":["deno","javascript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beingsuz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-22T22:01:32.000Z","updated_at":"2025-06-24T13:49:47.000Z","dependencies_parsed_at":"2025-06-13T03:23:29.794Z","dependency_job_id":"23bfa52b-9077-4b7b-b45b-b1a15070baad","html_url":"https://github.com/beingsuz/uwu-template","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/beingsuz/uwu-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beingsuz%2Fuwu-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beingsuz%2Fuwu-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beingsuz%2Fuwu-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beingsuz%2Fuwu-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beingsuz","download_url":"https://codeload.github.com/beingsuz/uwu-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beingsuz%2Fuwu-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266217170,"owners_count":23894242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","javascript"],"created_at":"2025-07-21T05:01:15.860Z","updated_at":"2026-04-11T01:57:27.458Z","avatar_url":"https://github.com/beingsuz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"uwu.png\" alt=\"UWU Template\" width=\"128\" height=\"128\"\u003e\n\n# UWU-Template 🦄\n\nA **blazingly fast, feature-rich template engine** for Deno and JavaScript with\nadvanced component system, helper functions, template inheritance, and\nperformance that rivals native template literals.\n\n\u003c/div\u003e\n\n## ✨ Features\n\n- 🚀 **Ultra-fast performance** - 3-6x faster than popular alternatives\n- 🧩 **Advanced component system** - Reusable templates with props and parent\n  data access\n- 🔧 **Enhanced helper functions** - Mixed string/variable arguments with type\n  safety\n- 🏗️ **Template inheritance** - Extensible templates with block overrides\n- 📝 **Rich templating** - Variables, conditionals, loops, layouts, and raw\n  blocks\n- 🛠️ **Enhanced error handling** - Detailed error messages with line numbers and\n  context\n- 📦 **Lightweight** - Minimal dependencies, zero runtime overhead\n- ⚡ **Production-ready** - Battle-tested with comprehensive benchmarks\n- 🎯 **Type-safe** - Written in TypeScript with full type support\n- 📚 **Comprehensive documentation** - Complete guides and migration support\n\n## 🆕 New in Latest Version\n\n- ✨ **Enhanced Error Reporting** - Get detailed error messages with line\n  numbers and code context\n- 🧩 **Parent Data Access** - Components can access parent template data with\n  `@parent` syntax\n- 🔧 **Mixed Helper Arguments** - Use both string literals and variables in\n  helper functions\n- 📚 **Complete Documentation** - API reference, migration guides, and component\n  examples\n- 🏗️ **Template Inheritance Foundation** - Extensible template system\n  (foundation ready)\n- ⚡ **Improved Performance** - Better caching and error recovery\n\n## 📖 Table of Contents\n\n- [Features](#-features)\n- [Quick Start](#-quick-start)\n- [Core Template Syntax](#-core-template-syntax)\n- [Helper Functions](#-helper-functions)\n- [Enhanced Component System](#-enhanced-component-system)\n- [Template Inheritance](#️-template-inheritance-preview)\n- [Performance Benchmarks](#-performance-benchmarks)\n- [Documentation](#-documentation)\n- [Migration from Other Engines](#-migration-from-other-engines)\n- [Contributing](#-contributing)\n\n## 🚀 Quick Start\n\n### Installation\n\n```typescript\n// From CDN (recommended)\nimport {\n\tcompile,\n\tregisterComponent,\n\tregisterHelper,\n} from \"https://cdn.jsdelivr.net/gh/Aiko-Suzuki/uwu-template@main/bundle.js\";\n\n// Or locally\nimport { compile, registerComponent, registerHelper } from \"./mod.ts\";\n```\n\n### 🎨 VS Code Extension\n\nGet syntax highlighting, snippets, and IntelliSense for `.uwu` template files:\n\n**[📦 UWU-Template Language Support](https://marketplace.visualstudio.com/items?itemName=beingsuz.uwu-template-support)**\n\nFeatures:\n\n- 🌈 Syntax highlighting for `.uwu` files\n- 📝 Code snippets and auto-completion\n- 🔍 Template validation and error detection\n- 🎯 IntelliSense support\n\n### Basic Usage\n\n```typescript\nimport { compile } from \"./mod.ts\";\n\n// 1. Define your template\nconst template = `\n\u003cdiv class=\"user-profile\"\u003e\n  \u003ch1\u003e{{title}}\u003c/h1\u003e\n  \u003cp\u003eWelcome {{user.name}}!\u003c/p\u003e\n  {{#if user.premium}}\n    \u003cspan class=\"badge premium\"\u003ePremium Member\u003c/span\u003e\n  {{/if}}\n  \u003cul class=\"items\"\u003e\n    {{#each items}}\n      \u003cli\u003e{{name}} - ${{ price }}\u003c/li\u003e\n    {{/each}}\n  \u003c/ul\u003e\n\u003c/div\u003e`;\n\n// 2. Compile the template (with optional error context)\nconst render = compile(template, { escape: true }, \"userProfile\");\n\nconst data = {\n\ttitle: \"My Store\",\n\tuser: { name: \"Alice\", premium: true },\n\titems: [\n\t\t{ name: \"Widget A\", price: 29.99 },\n\t\t{ name: \"Widget B\", price: 19.99 },\n\t],\n};\n\nconst html = render(data);\nconsole.log(html);\n```\n\n### Error Handling\n\nUWU-Template now provides detailed error information to help you debug issues\nquickly:\n\n```typescript\nimport { compile, TemplateRuntimeError, TemplateSyntaxError } from \"./mod.ts\";\n\ntry {\n\tconst render = compile(template, { escape: true }, \"myTemplate\");\n\tconst result = render(data);\n} catch (error) {\n\tif (error instanceof TemplateSyntaxError) {\n\t\tconsole.log(`Syntax error in template \"${error.templateName}\":`);\n\t\tconsole.log(\n\t\t\t`Line ${error.line}, Column ${error.column}: ${error.message}`,\n\t\t);\n\t\tconsole.log(error.context); // Shows code context around the error\n\t}\n}\n```\n\n## 📚 Core Template Syntax\n\n### Variables\n\n```handlebars\n{{title}}           \u003c!-- Simple variable --\u003e\n{{user.name}}       \u003c!-- Nested property --\u003e\n{{items.0.price}}   \u003c!-- Array access --\u003e\n```\n\n### Conditionals\n\n```handlebars\n{{#if condition}}\n  Content when true\n{{#elseif otherCondition}}\n  Content when elseif is true  \n{{#else}}\n  Content when false\n{{/if}}\n\n\u003c!-- Complex conditions --\u003e\n{{#if user.isActive \u0026\u0026 user.premium}}\n  Premium active user content\n{{/if}}\n```\n\n### Loops\n\n```handlebars\n{{#each items}}\n  \u003cli\u003e{{name}} - ${{price}}\u003c/li\u003e\n{{/each}}\n\n{{#each users}}\n  \u003cdiv\u003eUser {{@index}}: {{name}}\u003c/div\u003e\n{{/each}}\n```\n\n### Layouts\n\n```typescript\nimport { registerLayout } from \"./mod.ts\";\n\nregisterLayout(\n\t\"main\",\n\t`\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\u003ctitle\u003e{{title}}\u003c/title\u003e\u003c/head\u003e\n\u003cbody\u003e\n  {{\u003e header}}\n  \u003cmain\u003e{{content}}\u003c/main\u003e\n  {{\u003e footer}}\n\u003c/body\u003e\n\u003c/html\u003e`,\n);\n\n// Use in templates\nconst template = `\n{{\u003e main}}\n\u003ch1\u003ePage Content\u003c/h1\u003e\n`;\n```\n\n### Raw Output\n\nFor outputting literal template syntax without processing, use raw blocks:\n\n```handlebars\n{{{{raw}}}}\n  \u003ch1\u003e{{{body}}}\u003c/h1\u003e\n  \u003cp\u003eThis {{variable}} will not be processed\u003c/p\u003e\n  {{#if condition}}{{value}}{{/if}}\n{{{{/raw}}}}\n```\n\n**Output:**\n\n```html\n\u003ch1\u003e{{{body}}}\u003c/h1\u003e\n\u003cp\u003eThis {{variable}} will not be processed\u003c/p\u003e\n{{#if condition}}{{value}}{{/if}}\n```\n\n**Use Cases:**\n\n- Generating template examples in documentation\n- Outputting template syntax for client-side processing\n- Creating code examples that contain template syntax\n- Bypassing template processing for specific content blocks\n\n## 🔧 Helper Functions\n\n### Built-in Helpers\n\n```handlebars\n{{{json data}}}     \u003c!-- JSON.stringify (unescaped) --\u003e\n{{{raw content}}}   \u003c!-- Unescaped content --\u003e\n```\n\n### Custom Helpers with String Literals\n\n```typescript\nimport { registerHelper } from \"./mod.ts\";\n\n// Register helpers with flexible argument types\nregisterHelper(\"uppercase\", (...args) =\u003e {\n\tconst text = args[0];\n\treturn String(text).toUpperCase();\n});\n\nregisterHelper(\"formatPrice\", (...args) =\u003e {\n\tconst price = args[0] as number;\n\tconst currency = args[1] as string || \"USD\";\n\tconst prefix = args[2] as string || \"\";\n\treturn `${prefix}${currency} ${price.toFixed(2)}`;\n});\n\nregisterHelper(\"dateFormat\", (...args) =\u003e {\n\tconst date = args[0];\n\tconst format = args[1] as string || \"short\";\n\tconst d = new Date(date);\n\treturn format === \"long\" ? d.toLocaleDateString() : d.toDateString();\n});\n```\n\n**Template Usage with Mixed Arguments:**\n\n```handlebars\n\u003c!-- String literals --\u003e\n{{{uppercase \"hello world\"}}}  \u003c!-- Output: HELLO WORLD --\u003e\n{{{formatPrice \"29.99\" \"EUR\"}}} \u003c!-- Output: EUR 29.99 --\u003e\n{{{dateFormat \"2025-01-01\" \"long\"}}} \u003c!-- Output: 1/1/2025 --\u003e\n\n\u003c!-- Variables --\u003e\n{{{uppercase userName}}}       \u003c!-- Uses variable value --\u003e\n{{{formatPrice product.price}}} \u003c!-- Default currency --\u003e\n\n\u003c!-- Mixed string literals and variables --\u003e\n{{{formatPrice productPrice \"GBP\" \"Sale: \"}}} \u003c!-- Variable + string literals --\u003e\n{{{formatPrice price currency prefix}}}       \u003c!-- All variables --\u003e\n```\n\n### Block Helpers\n\n```typescript\nimport { registerBlockHelper } from \"./mod.ts\";\n\nregisterBlockHelper(\"withUser\", (user, options) =\u003e {\n\tif (user?.active) {\n\t\treturn options.fn(user);\n\t} else {\n\t\treturn options.inverse();\n\t}\n});\n```\n\n**Usage:**\n\n```handlebars\n{{#withUser currentUser}}\n  \u003cp\u003eWelcome {{name}}!\u003c/p\u003e\n{{#else}}\n  \u003cp\u003ePlease log in\u003c/p\u003e\n{{/withUser}}\n```\n\n## 🧩 Component System\n\nComponents are reusable template fragments with their own props and access to\nparent data.\n\n### Registering Components\n\n```typescript\nimport { registerComponent } from \"./mod.ts\";\n\n// Simple component\nregisterComponent(\"greeting\", \"Hello {{name}}!\");\n\n// Complex component with layout\nregisterComponent(\n\t\"userCard\",\n\t`\n\u003cdiv class=\"user-card\"\u003e\n  \u003cdiv class=\"avatar\"\u003e\n    \u003cimg src=\"{{avatar}}\" alt=\"{{name}}\"\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"info\"\u003e\n    \u003ch3\u003e{{name}}\u003c/h3\u003e\n    \u003cp\u003e{{email}}\u003c/p\u003e\n    {{#if @parent.showStatus}}\n      \u003cspan class=\"status {{#if active}}online{{#else}}offline{{/if}}\"\u003e\n        {{#if active}}🟢 Online{{#else}}⚫ Offline{{/if}}\n      \u003c/span\u003e\n    {{/if}}\n  \u003c/div\u003e\n\u003c/div\u003e`,\n);\n\n// Component composition\nregisterComponent(\n\t\"button\",\n\t`\u003cbutton class=\"btn btn-{{variant}}\" {{#if disabled}}disabled{{/if}}\u003e{{text}}\u003c/button\u003e`,\n);\n\nregisterComponent(\n\t\"modal\",\n\t`\n\u003cdiv class=\"modal\"\u003e\n  \u003cdiv class=\"modal-header\"\u003e\n    \u003ch2\u003e{{title}}\u003c/h2\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"modal-body\"\u003e\n    {{message}}\n  \u003c/div\u003e\n  \u003cdiv class=\"modal-footer\"\u003e\n    {{component \"button\" text=\"OK\" variant=\"primary\"}}\n    {{component \"button\" text=\"Cancel\" variant=\"secondary\"}}\n  \u003c/div\u003e\n\u003c/div\u003e`,\n);\n```\n\n### Using Components\n\n```handlebars\n\u003c!-- Simple usage --\u003e\n{{component \"greeting\" name=\"Alice\"}}\n\n\u003c!-- String literals and variables --\u003e\n{{component \"userCard\" \n  name=\"John Doe\" \n  email=\"john@example.com\"\n  avatar=user.profileImage\n  active=user.isOnline}}\n\n\u003c!-- Nested components --\u003e\n{{component \"modal\" \n  title=\"Confirm Action\" \n  message=\"Are you sure you want to continue?\"}}\n```\n\n### Parent Data Access\n\nComponents can access parent template data using `@parent`:\n\n```typescript\nregisterComponent(\n\t\"statusBadge\",\n\t`\n\u003cspan class=\"badge {{#if @parent.isActive}}badge-success{{#else}}badge-danger{{/if}}\"\u003e\n  {{status}} ({{@parent.userCount}} users)\n\u003c/span\u003e`,\n);\n```\n\n**Usage:**\n\n```handlebars\n{{component \"statusBadge\" status=\"Online\"}}\n\u003c!-- Component receives: {status: \"Online\", @parent: parentData} --\u003e\n```\n\n### Enhanced Component System\n\nUWU-Template features a powerful component system that supports props, parent\ndata access, and composition.\n\n### Component Registration\n\n```typescript\nimport { registerComponent } from \"./mod.ts\";\n\nregisterComponent(\n\t\"userCard\",\n\t`\n\u003cdiv class=\"user-card\"\u003e\n  \u003cimg src=\"{{avatar}}\" alt=\"{{name}}\" class=\"avatar\"\u003e\n  \u003ch3\u003e{{name}}\u003c/h3\u003e\n  \u003cp class=\"email\"\u003e{{email}}\u003c/p\u003e\n  \u003cspan class=\"role {{@parent.theme}}-badge\"\u003e{{role}}\u003c/span\u003e\n\u003c/div\u003e\n`,\n);\n```\n\n### Parent Data Access\n\nComponents can access the parent template's data using the `@parent` syntax:\n\n```typescript\nconst data = {\n\ttheme: \"dark\",\n\tusers: [\n\t\t{ name: \"Alice\", email: \"alice@example.com\", role: \"Admin\" },\n\t\t{ name: \"Bob\", email: \"bob@example.com\", role: \"User\" },\n\t],\n};\n```\n\n```handlebars\n\u003cdiv class=\"user-list\"\u003e\n  {{#each users}}\n    {{component \"userCard\" \n      name=name \n      email=email \n      role=role \n      avatar=\"/avatars/default.jpg\"}}\n  {{/each}}\n\u003c/div\u003e\n\u003c!-- Each component can access @parent.theme for styling --\u003e\n```\n\n### Component Composition\n\nBuild complex UIs by composing smaller components:\n\n```typescript\nregisterComponent(\n\t\"button\",\n\t`\n\u003cbutton class=\"btn btn-{{variant}} {{#if @parent.disabled}}disabled{{/if}}\" \n        type=\"{{type}}\"\u003e\n  {{text}}\n\u003c/button\u003e\n`,\n);\n\nregisterComponent(\n\t\"productCard\",\n\t`\n\u003cdiv class=\"product-card\"\u003e\n  \u003ch3\u003e{{name}}\u003c/h3\u003e\n  \u003cp class=\"price\"\u003e\\${{price}}\u003c/p\u003e\n  {{component \"button\" text=\"Add to Cart\" variant=\"primary\" type=\"button\"}}\n  {{component \"button\" text=\"♡ Wishlist\" variant=\"outline\" type=\"button\"}}\n\u003c/div\u003e\n`,\n);\n```\n\n## 🎨 Real-World Examples\n\n### E-commerce Product List\n\n```typescript\n// Register components\nregisterComponent(\n\t\"productCard\",\n\t`\n\u003cdiv class=\"product-card\"\u003e\n  \u003cimg src=\"{{image}}\" alt=\"{{name}}\"\u003e\n  \u003ch3\u003e{{name}}\u003c/h3\u003e\n  \u003cp class=\"price\"\u003e{{{formatPrice price @parent.currency}}}\u003c/p\u003e\n  {{#if onSale}}\n    \u003cspan class=\"sale-badge\"\u003eOn Sale!\u003c/span\u003e\n  {{/if}}\n  {{component \"button\" text=\"Add to Cart\" variant=\"primary\"}}\n\u003c/div\u003e`,\n);\n\n// Template\nconst template = `\n\u003cdiv class=\"product-grid\"\u003e\n  {{#each products}}\n    {{component \"productCard\" \n      name=name \n      price=price \n      image=image \n      onSale=onSale}}\n  {{/each}}\n\u003c/div\u003e`;\n\n// Data\nconst data = {\n\tcurrency: \"USD\",\n\tproducts: [\n\t\t{\n\t\t\tname: \"iPhone 15\",\n\t\t\tprice: 999,\n\t\t\timage: \"/iphone15.jpg\",\n\t\t\tonSale: false,\n\t\t},\n\t\t{\n\t\t\tname: \"MacBook Pro\",\n\t\t\tprice: 2499,\n\t\t\timage: \"/macbook.jpg\",\n\t\t\tonSale: true,\n\t\t},\n\t],\n};\n```\n\n### Blog with Layout System\n\n```typescript\nregisterLayout(\n\t\"blogLayout\",\n\t`\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003e{{title}} - {{@parent.siteName}}\u003c/title\u003e\n  \u003cmeta charset=\"utf-8\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  {{\u003e header}}\n  \u003cmain\u003e{{content}}\u003c/main\u003e\n  {{\u003e footer}}\n\u003c/body\u003e\n\u003c/html\u003e`,\n);\n\nregisterComponent(\n\t\"articleCard\",\n\t`\n\u003carticle class=\"article-card\"\u003e\n  \u003ch2\u003e\u003ca href=\"/posts/{{slug}}\"\u003e{{title}}\u003c/a\u003e\u003c/h2\u003e\n  \u003cdiv class=\"meta\"\u003e\n    \u003cspan class=\"author\"\u003eBy {{author}}\u003c/span\u003e\n    \u003cspan class=\"date\"\u003e{{{dateFormat publishedAt \"long\"}}}\u003c/span\u003e\n  \u003c/div\u003e\n  \u003cp class=\"excerpt\"\u003e{{excerpt}}\u003c/p\u003e\n  {{component \"button\" text=\"Read More\" variant=\"outline\"}}\n\u003c/article\u003e`,\n);\n\nconst template = `\n{{\u003e blogLayout}}\n\u003cdiv class=\"blog-posts\"\u003e\n  {{#each posts}}\n    {{component \"articleCard\" \n      title=title \n      slug=slug \n      author=author \n      publishedAt=publishedAt \n      excerpt=excerpt}}\n  {{/each}}\n\u003c/div\u003e`;\n```\n\n## 🏗️ Template Inheritance (Preview)\n\nUWU-Template includes a foundation for template inheritance, allowing you to\nextend base templates:\n\n```typescript\nimport { registerBaseTemplate } from \"./mod.ts\";\n\n// Register a base template\nregisterBaseTemplate(\n\t\"basePage\",\n\t`\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003e{{#block \"title\"}}Default Title{{/block}}\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cheader\u003e{{#block \"header\"}}Default Header{{/block}}\u003c/header\u003e\n  \u003cmain\u003e{{#block \"content\"}}Default Content{{/block}}\u003c/main\u003e\n  \u003cfooter\u003e{{#block \"footer\"}}Default Footer{{/block}}\u003c/footer\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n`,\n);\n```\n\n```handlebars\n\u003c!-- Child template extends base --\u003e\n{{extends \"basePage\"}}\n\n{{#block \"title\"}}My Custom Page{{/block}}\n\n{{#block \"content\"}}\n  \u003ch1\u003eWelcome!\u003c/h1\u003e\n  \u003cp\u003eThis content overrides the base template.\u003c/p\u003e\n{{/block}}\n```\n\n_Note: Template inheritance is currently in development. The foundation is\ncomplete and ready for full implementation._\n\n## 📊 Performance Benchmarks\n\n**🚀 Performance Summary:**\n\n- **1.7x faster** than Pug\n- **4-7x faster** than Handlebars, EJS, and Mustache\n- **Identical performance** to native Template Literals\n- **Fastest** template engine in most scenarios\n- **Enhanced caching** for better performance with error handling\n- **Sub-millisecond** compilation times for complex templates\n\n### Detailed Results\n\n| Template Engine   | Simple Templates | Complex Templates | Large Templates |\n| ----------------- | ---------------- | ----------------- | --------------- |\n| **UWU-Template**  | **374.2 ns**     | **24.9 µs**       | **300.1 µs**    |\n| Template Literals | 362.3 ns         | 24.9 µs           | 396.0 µs        |\n| Pug               | 536.9 ns         | 41.5 µs           | 518.2 µs        |\n| Mustache          | 2.3 µs           | 106.8 µs          | 1.2 ms          |\n| Handlebars        | 5.1 µs           | 111.9 µs          | 1.2 ms          |\n| EJS               | 2.9 µs           | 170.5 µs          | 1.7 ms          |\n\n### Real-World Performance\n\n- **E-commerce templates**: 48,913 renders/sec (0.020ms per render)\n- **Blog post templates**: 128,739 renders/sec (0.008ms per render)\n- **Email templates**: 365,141 renders/sec (0.003ms per render)\n\n📊 **[View complete benchmark results](./BENCHMARK_RESULTS.md)**\n\n### Run Benchmarks Yourself\n\n```bash\ndeno task bench\n```\n\n📈 **[View detailed benchmark results](./BENCHMARK_RESULTS.md)**\n\n## 🛠️ Advanced Usage\n\n### File-based Templates\n\n```js\n// Read template from file\nconst template = await Deno.readTextFile(\"./templates/layout.html\");\nconst render = compile(template);\n\nconst result = render({\n\ttitle: \"My Website\",\n\tcontent: \"Hello, world!\",\n});\n```\n\n## ⚡ Performance Benchmarks\n\nUWU-Template consistently outperforms popular template engines:\n\n```\nTemplate Engine Performance (renders/second):\n┌─────────────────┬──────────────────┬────────────────┐\n│ Engine          │ Simple Templates │ Complex Templates │\n├─────────────────┼──────────────────┼────────────────┤\n│ UWU-Template    │ 283,763/s        │ 38,939/s       │\n│ Handlebars      │ 85,000/s         │ 12,000/s       │\n│ EJS             │ 72,000/s         │ 15,000/s       │\n│ Mustache        │ 95,000/s         │ 18,000/s       │\n│ Template Literals│ 290,000/s       │ 45,000/s       │\n└─────────────────┴──────────────────┴────────────────┘\n\nUWU-Template is 3-6x faster than alternatives!\n```\n\n### Why So Fast?\n\n- **Compilation-based**: Templates are compiled to optimized JavaScript\n  functions\n- **Zero runtime dependencies**: No parsing overhead during rendering\n- **Smart caching**: Compiled templates are cached for reuse\n- **Minimal overhead**: Direct property access with optional chaining\n- **Optimized code generation**: Hand-tuned JavaScript output\n\n### Benchmark Details\n\n```typescript\n// Run benchmarks yourself\ndeno task bench\n\n// Or manually\ndeno run --allow-read bench/performance.bench.ts\n```\n\n## 📖 Complete API Reference\n\n### Core Functions\n\n#### `compile(template, options?)`\n\nCompiles a template string into a render function.\n\n```typescript\ninterface CompilerOptions {\n\tescape?: boolean; // Default: true\n}\n\nconst render = compile(templateString, { escape: false });\nconst html = render(data);\n```\n\n#### `registerHelper(name, function)`\n\nRegisters a custom helper function.\n\n```typescript\nregisterHelper(\"helperName\", (...args: unknown[]) =\u003e {\n\t// Helper logic\n\treturn \"result\";\n});\n```\n\n#### `registerBlockHelper(name, function)`\n\nRegisters a block helper with `fn` and `inverse` support.\n\n```typescript\nregisterBlockHelper(\n\t\"blockName\",\n\t(context: unknown, options: BlockHelperOptions) =\u003e {\n\t\tif (condition) {\n\t\t\treturn options.fn(context);\n\t\t} else {\n\t\t\treturn options.inverse(context);\n\t\t}\n\t},\n);\n```\n\n#### `registerComponent(name, template)`\n\nRegisters a reusable component.\n\n```typescript\nregisterComponent(\n\t\"componentName\",\n\t`\n\u003cdiv\u003e{{prop1}} - {{@parent.parentData}}\u003c/div\u003e\n`,\n);\n```\n\n#### `registerLayout(name, template)`\n\nRegisters a layout template.\n\n```typescript\nregisterLayout(\n\t\"layoutName\",\n\t`\n\u003chtml\u003e\n  \u003cbody\u003e{{content}}\u003c/body\u003e\n\u003c/html\u003e\n`,\n);\n```\n\n### Template Syntax Reference\n\n#### Variables\n\n```handlebars\n{{variable}}              \u003c!-- Simple variable --\u003e\n{{object.property}}       \u003c!-- Nested property --\u003e\n{{array.0.property}}      \u003c!-- Array access --\u003e\n{{#if variable}}{{/if}}   \u003c!-- In conditionals --\u003e\n```\n\n#### Conditionals\n\n```handlebars\n\u003c!-- Basic if/else --\u003e\n{{#if condition}}\n  True content\n{{#else}}\n  False content\n{{/if}}\n\n\u003c!-- Multiple conditions --\u003e\n{{#if condition1}}\n  First\n{{#elseif condition2}}\n  Second\n{{#else}}\n  Default\n{{/if}}\n\n\u003c!-- Complex conditions --\u003e\n{{#if user.isActive \u0026\u0026 user.premium}}\n  Premium user content\n{{/if}}\n```\n\n#### Loops\n\n```handlebars\n\u003c!-- Basic loop --\u003e\n{{#each items}}\n  \u003cdiv\u003e{{name}}\u003c/div\u003e\n{{/each}}\n\n\u003c!-- With index --\u003e\n{{#each items}}\n  \u003cdiv\u003eItem {{@index}}: {{name}}\u003c/div\u003e\n{{/each}}\n\n\u003c!-- Nested loops --\u003e\n{{#each categories}}\n  \u003ch2\u003e{{name}}\u003c/h2\u003e\n  {{#each items}}\n    \u003cp\u003e{{name}}\u003c/p\u003e\n  {{/each}}\n{{/each}}\n```\n\n#### Helpers\n\n```handlebars\n\u003c!-- String literals --\u003e\n{{{helperName \"string literal\"}}}\n{{{helperName \"string\" \"another\"}}}\n\n\u003c!-- Variables --\u003e\n{{{helperName variable}}}\n{{{helperName variable1 variable2}}}\n\n\u003c!-- Mixed --\u003e\n{{{helperName variable \"string\" anotherVariable}}}\n```\n\n#### Components\n\n```handlebars\n\u003c!-- Simple component --\u003e\n{{component \"componentName\"}}\n\n\u003c!-- With props --\u003e\n{{component \"componentName\" prop1=\"value\" prop2=variable}}\n\n\u003c!-- Access parent data in component --\u003e\n\u003c!-- Inside component template: --\u003e\n\u003cdiv\u003e{{prop}} - {{@parent.parentVariable}}\u003c/div\u003e\n```\n\n#### Layouts\n\n```handlebars\n\u003c!-- Use layout --\u003e\n{{\u003e layoutName}}\n\n\u003c!-- Layout with content --\u003e\n{{\u003e layoutName}}\n\u003cp\u003eThis content goes into the layout\u003c/p\u003e\n```\n\n#### Raw Output\n\n```handlebars\n\u003c!-- Output literal template syntax --\u003e\n{{{{raw}}}}\n  \u003ch1\u003e{{{body}}}\u003c/h1\u003e\n  \u003cp\u003eThis {{variable}} will not be processed\u003c/p\u003e\n  {{#if condition}}{{value}}{{/if}}\n{{{{/raw}}}}\n```\n\n### Error Handling\n\nUWU-Template gracefully handles missing data:\n\n```typescript\nconst template = `{{user.name}} - {{user.missing.property}}`;\nconst render = compile(template);\nconst result = render({ user: { name: \"Alice\" } });\n// Output: \"Alice - \" (missing properties render as empty)\n```\n\n### TypeScript Support\n\nFull TypeScript support with proper typing:\n\n```typescript\nimport { compile, registerComponent, registerHelper } from \"./mod.ts\";\n\n// Type-safe helper registration\nregisterHelper(\"typedHelper\", (value: string, format: string) =\u003e {\n\treturn `${format}: ${value}`;\n});\n\n// Type-safe data passing\ninterface User {\n\tname: string;\n\temail: string;\n}\n\nconst render = compile(`Hello {{name}}!`);\nconst result = render({ name: \"Alice\" } as User);\n```\n\n### Production Tips\n\n#### Pre-compilation\n\n```typescript\n// Compile templates at startup, not per request\nconst templates = {\n\tuserProfile: compile(userProfileTemplate),\n\tdashboard: compile(dashboardTemplate),\n\temail: compile(emailTemplate),\n};\n\n// Fast rendering per request\napp.get(\"/profile\", (req, res) =\u003e {\n\tconst html = templates.userProfile(req.user);\n\tres.send(html);\n});\n```\n\n#### Component Libraries\n\n```typescript\n// Create reusable component libraries\nexport function registerUIComponents() {\n\tregisterComponent(\"button\", buttonTemplate);\n\tregisterComponent(\"card\", cardTemplate);\n\tregisterComponent(\"modal\", modalTemplate);\n\t// ... more components\n}\n\n// Use across your application\nregisterUIComponents();\n```\n\n#### Performance Optimization\n\n```typescript\n// Use unescaped output for trusted content\nconst template = `{{{trustedHtmlContent}}}`;\n\n// Minimize helper calls in loops\n{{#each largeArray}}\n  {{{precomputedValue}}} \u003c!-- Better than helper calls --\u003e\n{{/each}}\n\n// Cache component instances\nconst cachedComponents = new Map();\n```\n\n## 🔧 Advanced Features\n\n### Custom Block Helpers\n\n```typescript\nregisterBlockHelper(\"repeat\", (count: number, options) =\u003e {\n\tlet result = \"\";\n\tfor (let i = 0; i \u003c count; i++) {\n\t\tresult += options.fn({ index: i, value: i + 1 });\n\t}\n\treturn result;\n});\n```\n\n```handlebars\n{{#repeat 3}}\n  \u003cdiv\u003eItem {{value}} (index {{index}})\u003c/div\u003e\n{{/repeat}}\n```\n\n### Helper with Hash Options\n\n```typescript\nregisterHelper(\"link\", (text: string, options) =\u003e {\n\tconst url = options.hash?.url || \"#\";\n\tconst target = options.hash?.target || \"_self\";\n\treturn `\u003ca href=\"${url}\" target=\"${target}\"\u003e${text}\u003c/a\u003e`;\n});\n```\n\n```handlebars\n{{{link \"Click here\" url=\"https://example.com\" target=\"_blank\"}}}\n```\n\n### Complex Component Composition\n\n```typescript\nregisterComponent(\n\t\"dataTable\",\n\t`\n\u003ctable class=\"table\"\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      {{#each @parent.columns}}\n        \u003cth\u003e{{title}}\u003c/th\u003e\n      {{/each}}\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    {{#each rows}}\n      {{component \"tableRow\" rowData=this columns=@parent.columns}}\n    {{/each}}\n  \u003c/tbody\u003e\n\u003c/table\u003e`,\n);\n\nregisterComponent(\n\t\"tableRow\",\n\t`\n\u003ctr\u003e\n  {{#each columns}}\n    \u003ctd\u003e{{lookup ../rowData field}}\u003c/td\u003e\n  {{/each}}\n\u003c/tr\u003e`,\n);\n```\n\n## 🧪 Testing\n\nUWU-Template includes comprehensive tests:\n\n```bash\n# Run all tests\ndeno test --allow-read\n\n# Run specific test files  \ndeno test --allow-read production.test.ts\ndeno test --allow-read real-world.test.ts\n\n# Run benchmarks\ndeno run --allow-read bench/performance.bench.ts\n```\n\n## 🔧 Available Features\n\n| Feature                   | Status | Example                                |\n| ------------------------- | ------ | -------------------------------------- |\n| Variables                 | ✅     | `{{name}}`                             |\n| Nested Properties         | ✅     | `{{user.email}}`                       |\n| Conditionals              | ✅     | `{{#if active}}...{{/if}}`             |\n| Else/ElseIf               | ✅     | `{{#else}}...{{/else}}`                |\n| Complex Conditions        | ✅     | `{{#if a \u0026\u0026 b}}...{{/if}}`             |\n| Loops                     | ✅     | `{{#each items}}...{{/each}}`          |\n| Layouts                   | ✅     | `{{\u003e layoutName}}`                     |\n| Helpers (String Literals) | ✅     | `{{{helper \"string\"}}}`                |\n| Helpers (Variables)       | ✅     | `{{{helper variable}}}`                |\n| Helpers (Mixed)           | ✅     | `{{{helper var \"str\"}}}`               |\n| Block Helpers             | ✅     | `{{#blockHelper}}...{{/blockHelper}}`  |\n| Components                | ✅     | `{{component \"name\" prop=\"value\"}}`    |\n| Parent Data Access        | ✅     | `{{@parent.data}}`                     |\n| Component Composition     | ✅     | Components using components            |\n| HTML Escaping             | ✅     | Automatic (use `{{{...}}}` to disable) |\n| TypeScript Support        | ✅     | Full type safety                       |\n| Performance Optimization  | ✅     | Compilation-based rendering            |\n\n## 🚀 Migration from Other Engines\n\nUWU-Template provides clear migration paths from popular template engines. See\nour **[complete migration guide](./docs/MIGRATION_GUIDE.md)** for detailed\nexamples.\n\n### From Handlebars (4.5x Performance Improvement)\n\nUWU-Template is largely compatible with Handlebars syntax:\n\n```handlebars\n\u003c!-- These work exactly the same --\u003e\n{{variable}}\n{{#if condition}}...{{/if}}\n{{#each items}}...{{/each}}\n\n\u003c!-- UWU-Template enhancements --\u003e\n{{component \"name\" prop=\"value\"}}     \u003c!-- Advanced components --\u003e\n{{{helper \"string literal\"}}}         \u003c!-- Mixed argument types --\u003e\n{{@parent.data}}                      \u003c!-- Parent data access --\u003e\n```\n\n**Migration effort**: ⭐ **Minimal** - Most templates work without changes\n\n### From EJS (6.8x Performance Improvement)\n\n```javascript\n// EJS\n\u003c%- include('partial', {data: value}) %\u003e\n\u003c% if (user.active) { %\u003eActive\u003c% } %\u003e\n\n// UWU-Template  \n{{component \"partial\" data=value}}\n{{#if user.active}}Active{{/if}}\n```\n\n**Migration effort**: ⭐⭐⭐ **Moderate** - Syntax changes but clear patterns\n\n### From Mustache (4.3x Performance Improvement)\n\n```handlebars\n\u003c!-- Mustache --\u003e\n{{#items}}{{name}}{{/items}}\n\n\u003c!-- UWU-Template (same syntax + more features) --\u003e\n{{#each items}}{{name}}{{/each}}\n{{component \"itemCard\" name=name}}\n```\n\n**Migration effort**: ⭐⭐ **Easy** - Similar syntax with more capabilities\n\n### From Pug (1.7x Performance + 2655x Faster Compilation)\n\n```pug\n// Pug\ndoctype html\nhtml\n  head\n    title= title\n  body\n    each item in items\n      li= item.name\n\n// UWU-Template\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\u003ctitle\u003e{{title}}\u003c/title\u003e\u003c/head\u003e\n\u003cbody\u003e\n  {{#each items}}\u003cli\u003e{{name}}\u003c/li\u003e{{/each}}\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n**Migration effort**: ⭐⭐⭐⭐ **Significant** - Complete restructure but major\nperformance gains\n\n### Migration Support Tools\n\n- **[Migration Guide](./docs/MIGRATION_GUIDE.md)** - Step-by-step conversion\n  guides\n- **Performance Comparisons** - Before/after benchmarks\n- **Syntax Converters** - Patterns for common conversions\n- **Best Practices** - Optimization tips for each engine\n\n## 📚 Documentation\n\nUWU-Template now includes comprehensive documentation to help you get started\nquickly:\n\n### 📖 Complete Guides\n\n- **[API Reference](./docs/API_REFERENCE.md)** - Complete API documentation with\n  examples\n- **[Migration Guide](./docs/MIGRATION_GUIDE.md)** - Migrate from Handlebars,\n  EJS, Mustache, Pug\n- **[Component Examples](./docs/COMPONENT_EXAMPLES.md)** - Real-world component\n  patterns\n- **[Performance Benchmarks](./BENCHMARK_RESULTS.md)** - Detailed performance\n  analysis\n\n### 🚀 Quick References\n\n- **Template Syntax** - Variables, conditionals, loops, and more\n- **Component System** - Props, composition, and parent data access\n- **Helper Functions** - Custom functions with mixed argument types\n- **Error Handling** - Debugging with detailed error messages\n- **Performance Tips** - Optimization strategies and best practices\n\n### 🔧 Development Resources\n\n- **TypeScript Support** - Full type definitions included\n- **Error Recovery** - Graceful handling of template issues\n- **Debugging Tools** - Line numbers and code context in errors\n- **Migration Helpers** - Tools to convert from other engines\n\n## 🤝 Contributing\n\nWe welcome contributions! Here's how to get started:\n\n1. **Fork the repository**\n2. **Create a feature branch**: `git checkout -b feature/amazing-feature`\n3. **Run tests**: `deno test -A`\n4. **Run benchmarks**: `deno task bench`\n5. **Add your changes with tests**\n6. **Update documentation** if needed\n7. **Commit**: `git commit -m 'Add amazing feature'`\n8. **Push**: `git push origin feature/amazing-feature`\n9. **Open a Pull Request**\n\n### Development Setup\n\n```bash\n# Clone the repo\ngit clone https://github.com/your-username/uwu-template.git\ncd uwu-template\n\n# Run tests (all should pass)\ndeno test -A\n\n# Run enhanced features demo\ndeno run -A enhanced-demo.ts\n\n# Run benchmarks\ndeno task bench\n\n# Check formatting\ndeno fmt --check\n\n# Check linting\ndeno lint\n\n# Build bundle\ndeno task build\n```\n\n### Documentation\n\n- All public APIs are documented in `docs/API_REFERENCE.md`\n- Component examples are in `docs/COMPONENT_EXAMPLES.md`\n- Migration guides are in `docs/MIGRATION_GUIDE.md`\n- Update documentation when adding features\n\n### Testing\n\n- Add tests for new features in appropriate test files\n- Ensure backward compatibility\n- Test error handling scenarios\n- Benchmark performance impact for major changes\n\n## 🌟 Sponsor\n\nThis project is proudly sponsored by [yatsu.net](https://yatsu.net)\n\n## 📄 License\n\nMIT License - see the [LICENSE](LICENSE) file for details.\n\n## � Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for a complete list of changes and version\nhistory.\n\n## �🙏 Acknowledgments\n\n- Inspired by Handlebars, Mustache, and EJS\n- Built for the Deno community\n- Performance benchmarks against industry standards\n- Enhanced with comprehensive documentation and developer experience\n  improvements\n\n---\n\n## 🎯 What's Next?\n\n- 🏗️ **Complete Template Inheritance** - Full block override system\n- 🔧 **Advanced Helper Features** - More built-in helpers and utilities\n- 🚀 **Streaming Templates** - Support for large dataset streaming\n- 📱 **Framework Integrations** - Plugins for popular frameworks\n- 🎨 **Template Designer** - Visual template builder\n\n**🦄 Made with care for modern web development**\n\n_UWU-Template: Because your templates deserve to be fast AND adorable!_\n\n📊 **Performance** • 🧩 **Components** • 🔧 **Helpers** • 📚 **Documentation** •\n🚀 **Migration**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeingsuz%2Fuwu-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeingsuz%2Fuwu-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeingsuz%2Fuwu-template/lists"}