{"id":18676119,"url":"https://github.com/cstrlcs/tinyplate","last_synced_at":"2026-02-15T15:43:03.968Z","repository":{"id":227742141,"uuid":"772302533","full_name":"cstrlcs/tinyplate","owner":"cstrlcs","description":"A dead simple templating (\u003c38 LOC) engine written in pure typescript.","archived":false,"fork":false,"pushed_at":"2025-03-14T13:05:08.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-10T23:33:54.290Z","etag":null,"topics":["javascript","templating-engine","templating-language"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cstrlcs.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":"2024-03-14T23:27:29.000Z","updated_at":"2025-08-18T05:25:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"5f690b33-dae7-4c40-9adc-0bfcac05e380","html_url":"https://github.com/cstrlcs/tinyplate","commit_stats":null,"previous_names":["cstrlcs/tinyplate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cstrlcs/tinyplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrlcs%2Ftinyplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrlcs%2Ftinyplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrlcs%2Ftinyplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrlcs%2Ftinyplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cstrlcs","download_url":"https://codeload.github.com/cstrlcs/tinyplate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrlcs%2Ftinyplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29482696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T15:33:17.885Z","status":"ssl_error","status_checked_at":"2026-02-15T15:32:53.698Z","response_time":118,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["javascript","templating-engine","templating-language"],"created_at":"2024-11-07T09:27:44.375Z","updated_at":"2026-02-15T15:43:03.963Z","avatar_url":"https://github.com/cstrlcs.png","language":"TypeScript","readme":"\u003c!-- This file is generated using tinyplate. Do not edit directly. --\u003e\n# tinyplate\n\nTinyplate is a dead simple templating engine written in pure typescript. It is designed to be super fast, minimal, with zero dependencies and easy to use.\n\nIt's tiny with only 37 lines of code and a size of 583 bytes when bundled.\n\n## Features\n\n- Has 0 dependencies\n- Extremely fast\n- Supports HTML encoding\n- Requires no options or configurations for use\n- Works in Node, Bun, Deno, browser, and even your toaster (probably)\n\nThe bundle even fits here:\n\n```javascript\nvar g=/`|\\\\/g,a=/\\\\(`|\\\\)/g,p=/[\\r\\t\\n]/g,E=/\u003c%=([\\s\\S]+?)%\u003e/g,i=/\u003c%!([\\s\\S]+?)%\u003e/g,l=/\u003c%([\\s\\S]+?(\\}?)+)%\u003e/g,_=/\\n`;/g;function u(c,o){let t=(n)=\u003en.replace(a,\"$1\").replace(p,\" \"),r=`const encode = ${((n)=\u003e{let e={\"\u0026\":\"\u0026#38;\",\"\u003c\":\"\u0026#60;\",\"\u003e\":\"\u0026#62;\",'\"':\"\u0026#34;\",\"'\":\"\u0026#39;\",\"/\":\"\u0026#47;\"};return n.replace(/\u0026(?!#?\\w+;)|\u003c|\u003e|\"|'|\\//g,(s)=\u003ee[s])}).toString()};let _=\\`${c.replace(g,\"\\\\$\u0026\").replace(E,(n,e)=\u003e`\\`+(${t(e)})+\\``).replace(i,(n,e)=\u003e`\\`+encode(${t(e)})+\\``).replace(l,(n,e)=\u003e`\\`;${t(e)};_+=\\``).replace(_,\"`;\")}\\`;return _;`;return new Function(\"it\",r)(o)}export{u as default};\n```\n\n## Important Considerations ⚠️\n\n- Tinyplate is extremely minimal; it does not have any options or configurations.\n- It allows arbitrary code execution in templates, which can be extremely powerful but also be dangerous. Do not use user input as part of the template.\n- Although it supports HTML encoding through `\u003c%! .. %\u003e` tags, the library is new and has not been fully tested against code injection. Use caution with untrusted input.\n- If you need more features out of the box, consider trying [doT](https://github.com/olado/doT) or [eta](https://eta.js.org/). Both are excellent tools that have inspired this library.\n\n## Usage\n\n- Install with `npm i tinyplate.js`\n- `\u003c% .. %\u003e` - for code blocks\n- `\u003c%= .. %\u003e` - for interpolations\n- `\u003c%! .. %\u003e` - for interpolations with HTML encoding\n\n## Examples\n\nYou can check some examples here and in the `examples` folder. Even this README is generated using tinyplate.\n\n### Basic example\n\n```javascript\nimport tinyplate from \"tinyplate.js\";\n\ntinyplate(\"\u003cli\u003e\u003c%= it.name %\u003e\u003c/li\u003e\", { name: \"tinyplate\" });\n```\n\n### Using a file\n\n```javascript\nimport fs from \"node:fs\";\nimport tinyplate from \"tinyplate.js\";\n\nconst template = fs.readFileSync(\"template.txt\", \"utf8\");\ntinyplate(template, { name: \"tinyplate\" });\n```\n\n### Layout and partials\n\n```javascript\nimport tinyplate from \"tinyplate.js\";\n\nconst LAYOUT_TEMPLATE = `\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003e\u003c%! it.title %\u003e\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003c%= it.body %\u003e\n\u003c/body\u003e`;\n\nconst BODY_TEMPLATE = `\n\u003cmain\u003e\n  \u003ch1\u003e\u003c%! it.content %\u003e\u003c/h1\u003e\n\u003c/main\u003e\n`;\n\nconst context = { title: \"tinyplate\", content: \"Hello, world!\" };\ntinyplate(LAYOUT_TEMPLATE, {\n\t...context,\n\tbody: tinyplate(BODY_TEMPLATE, context),\n});\n```\n\n### Logic\n\n```javascript\nimport tinyplate from \"tinyplate.js\";\n\nconst TEMPLATE = `\n\u003cdiv\u003e\n  \u003cul\u003e\n  \u003c% for (let i = 0; i \u003c it.amount; i++) { %\u003e\n    \u003cli\u003e\u003c%= i %\u003e\u003c/li\u003e\n  \u003c% } %\u003e\n  \u003c/ul\u003e\n\n  \u003c% if (it.name) { %\u003e\n    \u003cp\u003eHello, \u003c%= it.name %\u003e!\u003c/p\u003e\n  \u003c% } else { %\u003e\n    \u003cp\u003eHello, world!\u003c/p\u003e\n  \u003c% } %\u003e\n\u003c/div\u003e`;\n\ntinyplate(TEMPLATE, { name: \"tinyplate\", amount: 5 });\n```\n\n## Credits\n\nTinyplate is heavily inspired by [doT](https://github.com/olado/doT) and [eta](https://eta.js.org/).\nHuge thanks to the creators of `doT` from where I borrowed the regexes and some of the logic. Also, a big shoutout to the creators of `eta` for inspiring the templating syntax.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcstrlcs%2Ftinyplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcstrlcs%2Ftinyplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcstrlcs%2Ftinyplate/lists"}