{"id":20314600,"url":"https://github.com/dashpilot/sub-template","last_synced_at":"2026-06-08T15:31:53.495Z","repository":{"id":164616081,"uuid":"639882822","full_name":"dashpilot/sub-template","owner":"dashpilot","description":"Simple template language that compiles to ES Modules for fast rendering on server, client or prerendered","archived":false,"fork":false,"pushed_at":"2023-05-16T00:33:01.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T08:45:15.350Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://sub-template.vercel.app","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dashpilot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-05-12T12:49:35.000Z","updated_at":"2023-05-12T23:15:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"9d38921d-eba2-49a9-a8b0-51f819fce2b4","html_url":"https://github.com/dashpilot/sub-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dashpilot/sub-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fsub-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fsub-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fsub-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fsub-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dashpilot","download_url":"https://codeload.github.com/dashpilot/sub-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fsub-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34069489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-14T18:16:00.986Z","updated_at":"2026-06-08T15:31:53.473Z","avatar_url":"https://github.com/dashpilot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sub-template\n\nSimple template engine that compiles to ES Modules for fast rendering on server, client or prerendered\nBased on Patrick Pissurno's wonderful https://github.com/patrickpissurno/li-template.\nI converted it to an ES Module and changed the code so it outputs ES Modules instead of CommonJS\n\n# About\n\nI was looking for a simple and fast template engine that would work with Vercel's Edge functions\n(which does not support filesystem operations or string-based template engines) and the most\nobvious choice was to use ES Module template literals. Creating a whole site as strings in ES Modules\nquickly becomes a drag, and that's when I stumbled across Patrick Pissurno's li-template which allows\nyou to write html files with simplified template literal syntax and compiles to CommonJS. I adapted it\nto compile to ES Modules so that you can easily use it with Edge Functions (SSR), in the browser (CSR)\nor prerendered (SSG).\n\n# Syntax\n\nThe syntax is exactly the same as li-template (although I might add to it in the future):\n\n### Exists (not null)\n\n**Short-hand**\n\n`$(data.something?){\u003cb\u003e${data.something}\u003c/b\u003e}`\n\n**Transpiles into**\n\n`` ${data.something ? `\u003cb\u003e${data.something}\u003c/b\u003e` : ''} ``\n\n### Does not exist or empty\n\n**Short-hand**\n\n`$(!data.something?){\u003cb\u003eEmpty\u003c/b\u003e}`\n\n**Transpiles into**\n\n`` ${data.something == null || data.something.length === 0 ? `\u003cb\u003eEmpty\u003c/b\u003e` : ''} ``\n\n### Loops\n\n**Short-hand**\n\n`$(data.names:name){\u003cb\u003eI'm ${name}\u003c/b\u003e}`\n\n**Transpiles into**\n\n`` ${data.names.map(x =\u003e `\u003cb\u003eI'm ${x.name}\u003c/b\u003e`).join('')} ``\n\n## Basic syntax\n\nInside `${}` you can use whatever from Javascript you would like to. Functions, methods, properties, process.env... Whatever. Just keep in mind that whatever you do write in there, would have to work with plain `${}` template literals in Node.js module context.\n\n### String template (replace)\n\nThis one is just like plain ES6 template literals.\n\n`${data.something}`\n\nIt will be replaced at render time with _data.something_'s value.\n\n## How it works\n\n1. create your template as a .sub file in the `src` folder\n2. `actions/precompile.js` will compile the template to an ES Module in `public/template` at build time\n3. `actions/compile.js` shows you a simple example of how to render a template\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdashpilot%2Fsub-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdashpilot%2Fsub-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdashpilot%2Fsub-template/lists"}