{"id":20383892,"url":"https://github.com/hugodf/render-tmpl","last_synced_at":"2026-02-13T19:32:13.828Z","repository":{"id":258830870,"uuid":"875817944","full_name":"HugoDF/render-tmpl","owner":"HugoDF","description":"Use `\u003ctemplate\u003e` as a rendering engine, \u003c 100 lines of code.","archived":false,"fork":false,"pushed_at":"2024-10-20T23:08:54.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-26T04:33:11.907Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npm.im/render-tmpl","language":"JavaScript","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/HugoDF.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"HugoDF"}},"created_at":"2024-10-20T22:33:13.000Z","updated_at":"2024-10-21T07:23:36.000Z","dependencies_parsed_at":"2024-10-22T00:32:02.851Z","dependency_job_id":null,"html_url":"https://github.com/HugoDF/render-tmpl","commit_stats":null,"previous_names":["hugodf/render-tmpl"],"tags_count":1,"template":false,"template_full_name":"HugoDF/node-mit-boilerplate","purl":"pkg:github/HugoDF/render-tmpl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HugoDF%2Frender-tmpl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HugoDF%2Frender-tmpl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HugoDF%2Frender-tmpl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HugoDF%2Frender-tmpl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HugoDF","download_url":"https://codeload.github.com/HugoDF/render-tmpl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HugoDF%2Frender-tmpl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29415591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":[],"created_at":"2024-11-15T02:24:55.582Z","updated_at":"2026-02-13T19:32:13.810Z","avatar_url":"https://github.com/HugoDF.png","language":"JavaScript","funding_links":["https://github.com/sponsors/HugoDF"],"categories":[],"sub_categories":[],"readme":"# `render-tmpl`\n\n![minzip size badge](https://badgen.net/bundlephobia/minzip/render-tmpl)\n\nUse `\u003ctemplate\u003e` as a rendering engine, [\u003c 100 lines of code](./render-tmpl.js).\n\n- Alpine/Vue-like directive notation `data-s-{text,attr,show}` for use with `\u003ctemplate\u003e` elements.\n- No reactivity, pairs well with web components/custom elements.\n- copy-paste onto your page ([\u003c 100 lines of code](./render-tmpl.js) or ESM import).\n\n## Quickstart\n\n```html\n\u003ctemplate data-s-tmpl=\"tmpl\"\u003e\n  \u003cdiv data-s-text=\"greeting\"\u003e\u003c/div\u003e\n  \u003cimg data-s-attr=\"src=url,alt=greeting\" /\u003e\n\u003c/template\u003e\n\u003cscript type=\"importmap\"\u003e\n  { \"imports\": { \"render-tmpl\": \"https://esm.sh/render-tmpl\" } }\n\u003c/script\u003e\n\u003cscript type=\"module\"\u003e\n  import { renderTmpl } from \"render-tmpl\";\n  document.appendChild(\n    renderTmpl(document.querySelector(\"[data-s-tmpl=tmpl]\"), {\n      greeting: \"hello\",\n      url: \"my-url\",\n    }),\n  );\n\u003c/script\u003e\n```\n\n## Directives\n\n### `data-s-tmpl`\n\n`data-s-tmpl` is a convention to denote templates that will be used with `render-tmpl`.\n\nUsage: `\u003ctemplate data-s-tmpl=\"loading\"\u003e\u003c/template\u003e`.\n\n### `data-s-show`\n\n`data-s-show` will set `display: none;` if the expression is false and will unset `display` if it's true.\n\nUsage: `\u003cdiv data-s-show=\"isShown\"\u003e\u003c/div\u003e`\n\nUse of negation is allowed with `!`, eg. `\u003cdiv data-s-show=\"!isLoading\"\u003e\u003c/div\u003e`, **note**: any arbitrary number of `!` works, but other boolean logic (`\u0026\u0026`, `||`, `()`) will **not work**, this is because the value is not `eval`-ed as JavaScript.\n\n### `data-s-text`\n\nSet the `textContent` of the node to the value of the referenced variable.\n\nUsage: `\u003cp data-s-text=\"message\"\u003e\u003c/p\u003e`\n\n### `data-s-attr`\n\nSet attributes on the element based on provided key-value `attr1=value1,attr2=value2` pairs.\n\nAliases: `data-s-attrs`\n\nUsage: `\u003cimg data-s-attr=\"src=url,alt=greeting\" /\u003e` sets `src` and `alt` attributes to the values contained in `url` and `greeting` variables.\n\n### `data-s-slot`\n\nUsed as the element into which sub-templates are injected.\n\nUsage:\n\n```html\n\u003ctemplate data-s-tmpl=\"tmpl\"\u003e\n  \u003cdiv data-s-slot\u003e\u003c/div\u003e\n  \u003ctemplate data-s-tmpl=\"no-results\"\u003e\n    No Results \u003cspan data-s-text=\"requestId\"\u003e\u003c/span\u003e\n  \u003c/template\u003e\n\u003c/template\u003e\n\u003cscript type=\"module\"\u003e\n  import { renderTmpl } from \"render-tmpl\";\n  document.appendChild(\n    renderTmpl(document.querySelector(\"[data-s-tmpl=tmpl]\"), {}, (tmpl) =\u003e\n      renderTmpl(tmpl.querySelector(\"[data-s-tmpl=no-results]\"), {\n        requestId: \"1234\",\n      }),\n    ),\n  );\n\u003c/script\u003e\n```\n\n\u003c!-- @todo\n- `$ctx.query` vs `$state.query` vs `$s.query` vs `$query`?\n- should there be a directive registration system? (would allow for increased modularity)?\n--\u003e\n\n## Requirements\n\n- Node 20\n- npm v8+\n\n## Setup\n\n1. Clone the repository\n2. Run `npm install` installs all required dependencies.\n\n## npm scripts\n\n- `npm test` will run tests using the [Node.js test runner](https://nodejs.org/api/test.html#running-tests-from-the-command-line) and the `node:test` module.\n- `npm run format` will run prettier on all the examples files (and tests).\n\n## LICENSE\n\nCode is licensed under the [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugodf%2Frender-tmpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhugodf%2Frender-tmpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugodf%2Frender-tmpl/lists"}