{"id":13806050,"url":"https://github.com/motss/lit-ntml","last_synced_at":"2025-04-13T08:21:39.147Z","repository":{"id":40461967,"uuid":"109403404","full_name":"motss/lit-ntml","owner":"motss","description":"Inspired by lit-html but for Node.js","archived":false,"fork":false,"pushed_at":"2023-06-06T02:36:58.000Z","size":1432,"stargazers_count":81,"open_issues_count":4,"forks_count":9,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-27T00:11:05.506Z","etag":null,"topics":["html","html-fragment","lit-html","lit-ntml","ntml","parse-html","parse5","tagged-template-literals","templating","typescript"],"latest_commit_sha":null,"homepage":"https://npm.im/lit-ntml","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/motss.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"code-of-conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":["motss"],"custom":["https://www.buymeacoffee.com/RLmMhgXFb"]}},"created_at":"2017-11-03T14:12:45.000Z","updated_at":"2025-02-11T15:49:50.000Z","dependencies_parsed_at":"2024-04-10T01:49:43.030Z","dependency_job_id":"e1145609-221c-46cd-a815-e02d8c7d114a","html_url":"https://github.com/motss/lit-ntml","commit_stats":{"total_commits":329,"total_committers":5,"mean_commits":65.8,"dds":0.05167173252279633,"last_synced_commit":"c4f8983ea36d132d6280fe89ac6e68d9679f62a1"},"previous_names":[],"tags_count":106,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motss%2Flit-ntml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motss%2Flit-ntml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motss%2Flit-ntml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motss%2Flit-ntml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/motss","download_url":"https://codeload.github.com/motss/lit-ntml/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681615,"owners_count":21144719,"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":["html","html-fragment","lit-html","lit-ntml","ntml","parse-html","parse5","tagged-template-literals","templating","typescript"],"created_at":"2024-08-04T01:01:07.392Z","updated_at":"2025-04-13T08:21:39.111Z","avatar_url":"https://github.com/motss.png","language":"TypeScript","funding_links":["https://github.com/sponsors/motss","https://www.buymeacoffee.com/RLmMhgXFb"],"categories":["Similar libraries"],"sub_categories":["Other Tools"],"readme":"\u003cdiv align=\"center\" style=\"text-align: center;\"\u003e\n  \u003ch1 style=\"border-bottom: none;\"\u003elit-ntml\u003c/h1\u003e\n\n  \u003cp\u003eInspired by \u003ca href=\"https://github.com/PolymerLabs/lit-html\" target=\"_blank\" rel=\"noopener\"\u003elit-html\u003c/a\u003e but for Node.js.\u003c/p\u003e\n\u003c/div\u003e\n\n\u003chr /\u003e\n\n[![Buy me a coffee][buy-me-a-coffee-badge]][buy-me-a-coffee-url]\n[![Follow me][follow-me-badge]][follow-me-url]\n\n[![npm-latest][npm-latest-badge]][npm-latest-url]\n[![MIT License][mit-license-badge]][mit-license-url]\n\n[![Downloads][downloads-badge]][downloads-url]\n[![Total downloads][total-downloads-badge]][downloads-url]\n\n[![Dependencies][dependencies-badge]][dependencies-url]\n[![ci][ga-ci-badge]][ga-ci-url]\n[![publish][ga-publish-badge]][ga-publish-url]\n[![codecov][codecov-badge]][codecov-url]\n\n[![Code of Conduct][coc-badge]][coc-url]\n\n\u003e Lightweight and modern templating for SSR in [Node.js][nodejs-url], inspired by [lit-html][lit-html-url].\n\nThis module also gets featured in [web-padawan/awesome-lit-html][web-padawan-awesome-lit-html-url]. Make sure to check the repo out for awesome things inspired by [lit-html][lit-html-url]. 👍💯\n\n## Table of contents \u003c!-- omit in toc --\u003e\n\n- [Features](#features)\n- [Pre-requisite](#pre-requisite)\n- [Enable syntax highlighting when writing HTML with template literal](#enable-syntax-highlighting-when-writing-html-with-template-literal)\n  - [Visual Studio Code](#visual-studio-code)\n- [Install](#install)\n- [Usage](#usage)\n  - [html()](#html)\n  - [htmlSync()](#htmlsync)\n  - [htmlFragment()](#htmlfragment)\n  - [htmlFragmentSync()](#htmlfragmentsync)\n  - [SSR with Express (Node.js)](#ssr-with-express-nodejs)\n  - [Browser support](#browser-support)\n- [API Reference](#api-reference)\n  - [html()](#html-1)\n  - [htmlSync()](#htmlsync-1)\n  - [htmlFragment()](#htmlfragment-1)\n  - [htmlFragmentSync()](#htmlfragmentsync-1)\n- [deno](#deno)\n- [License](#license)\n\n## Features\n\n| Support | Feature |\n| --- | --- |\n| ✅ | `await` all tasks including Functions, Promises, and whatnot. |\n| ✅ | Parse `PromiseList` or `List` by default, without explicit joining. |\n| ✅ | Support HTML syntax highlighting + autocompletion with [vscode-lit-html][vscode-lit-html-url] in JavaScript's template string. |\n\n## Pre-requisite\n\n- [Node.js][nodejs-url] \u003e= 16.x\n- [ES Modules]\n\n## Enable syntax highlighting when writing HTML with template literal\n\n### Visual Studio Code\n\n1. Install [vscode-lit-html][vscode-lit-html-url] extension.\n2. If the extension does not provide that syntax highlighting and autocompletion, try writing your templates in `.jsx` file (or `.tsx` file if you're [TypeScript][typescript-url] user) . That should work.\n\n## Install\n\n```sh\n# Install via NPM\n$ npm install lit-ntml\n```\n\n## Usage\n\n### html()\n\n```ts\nimport { html } from 'lit-ntml';\n\nconst peopleList = ['Cash Black', 'Vict Fisherman'];\nconst syncTask = () =\u003e `\u003ch1\u003eHello, World!\u003c/h1\u003e`;\nconst asyncLiteral = Promise.resolve('\u003ch2\u003eJohn Doe\u003c/h2\u003e');\nconst asyncListTask = async () =\u003e `\u003cul\u003e${peopleList.map(n =\u003e `\u003cli\u003e${n}\u003c/li\u003e`)}\u003c/ul\u003e`;\n\n/** Assuming top-level await is enabled... */\nawait html`${syncTask}${asyncLiteral}${asyncListTask}`; /** \u003c!DOCTYPE html\u003e\u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003ch1\u003eHello, World!\u003c/h1\u003e\u003ch2\u003eJohn Doe\u003c/h2\u003e\u003cul\u003e\u003cli\u003eCash Black\u003c/li\u003e\u003cli\u003eVict Fisherman\u003c/li\u003e\u003c/ul\u003e\u003c/body\u003e\u003c/html\u003e */\n```\n\n### htmlSync()\n\n```ts\nimport { htmlSync as html } from 'lit-ntml';\n\nconst peopleList = ['Cash Black', 'Vict Fisherman'];\nconst syncTask = () =\u003e `\u003ch1\u003eHello, World!\u003c/h1\u003e`;\n\nhtml`${syncTask}${peopleList}`;\n/** \u003c!DOCTYPE html\u003e\u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003ch1\u003eHello, World!\u003c/h1\u003eCash BlackVictFisherman[object Promise]\u003c/body\u003e\u003c/html\u003e */\n```\n\n### htmlFragment()\n\n```ts\nimport { htmlFragment as html } from 'lit-ntml';\n\nconst syncTask = () =\u003e `\u003ch1\u003eHello, World!\u003c/h1\u003e`;\nconst externalStyleLiteral = `\u003cstyle\u003ebody { margin: 0; padding: 0; box-sizing: border-box; }\u003c/style\u003e`;\n\n/** Assuming top-level await is enabled... */\nawait html`${externalStyleLiteral}${syncTask}`; /** \u003cstyle\u003ebody { margin: 0; padding: 0; box-sizing: border-box; }\u003c/style\u003e\u003ch1\u003eHello, World!\u003c/h1\u003e */\n```\n\n### htmlFragmentSync()\n\n```ts\nimport { htmlFragmentSync as html } from 'lit-ntml';\n\nconst peopleList = ['Cash Black', 'Vict Fisherman'];\nconst syncTask = () =\u003e `\u003ch1\u003eHello, World!\u003c/h1\u003e`;\nconst asyncTask = Promise.resolve(1);\n\nhtml`${syncTask}${peopleList}${asyncTask}`;\n/** \u003ch1\u003eHello, World!\u003c/h1\u003eCash BlackVictFisherman[object Promise] */\n```\n\n### SSR with Express (Node.js)\n\n[![Edit SSR with Express and LitNtml](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/ssr-with-express-and-litntml-4tbv9?fontsize=14)\n\n### Browser support\n\nOnly modern browsers with native [ES Modules] support requires no polyfills and transpilation needed.\n\n```html\n\u003c!doctype html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cscript type=\"module\"\u003e\n      import { html } from 'https://esm.sh/lit-ntml@latest';\n\n      // --snip\n    \u003c/script\u003e\n  \u003c/head\u003e\n\u003c/html\u003e\n```\n\n## API Reference\n\n### html()\n\n- returns: \u003c[Promise][promise-mdn-url]\u003c[string][string-mdn-url]\u003e\u003e Promise which resolves with rendered HTML document string.\n\n### htmlSync()\n\nThis method works the same as [html()] except that this is the synchronous version.\n\n### htmlFragment()\n\n- returns: \u003c[Promise][promise-mdn-url]\u003c[string][string-mdn-url]\u003e\u003e Promise which resolves with rendered HTML document fragment string.\n\n### htmlFragmentSync()\n\nThis method works the same as [htmlFragment()] except that this is the synchronous version.\n\n## deno\n\n👉 Check out the [deno] module at [deno_mod/lit_ntml].\n\n## License\n\n[MIT License](https://motss.mit-license.org) © Rong Sen Ng\n\n\n\n\u003c!-- References --\u003e\n[deno_mod/lit_ntml]: https://github.com/motss/deno_mod/tree/master/lit_ntml\n[deno]: https://github.com/denoland/deno\n[ES Modules]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules\n[html()]: #html-1\n[htmlFragment()]: #htmlfragment-1\n[lit-html-url]: https://github.com/PolymerLabs/lit-html\n[nodejs-url]: https://nodejs.org\n[typescript-url]: https://github.com/Microsoft/TypeScript\n[vscode-lit-html-url]: https://github.com/mjbvz/vscode-lit-html\n[web-padawan-awesome-lit-html-url]: https://github.com/web-padawan/awesome-lit-html\n\n\u003c!-- MDN --\u003e\n[boolean-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean\n[html-style-element-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLStyleElement\n[map-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\n[number-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number\n[object-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\n[promise-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise\n[string-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\n\n\u003c!-- Badges --\u003e\n[buy-me-a-coffee-badge]: https://img.shields.io/badge/buy%20me%20a-coffee-ff813f?logo=buymeacoffee\u0026style=flat-square\n[follow-me-badge]: https://img.shields.io/badge/follow-@igarshmyb-1d9bf0?logo=twitter\u0026style=flat-square\n\n[npm-latest-badge]: https://img.shields.io/npm/v/lit-ntml?color=blue\u0026logo=npm\u0026style=flat-square\n[mit-license-badge]: https://img.shields.io/npm/l/lit-ntml?color=blue\u0026style=flat-square\n\n[downloads-badge]: https://img.shields.io/npm/dm/lit-ntml?style=flat-square\n[total-downloads-badge]: https://img.shields.io/npm/dt/lit-ntml?label=total%20downloads\u0026style=flat-square\n\n[dependencies-badge]: https://img.shields.io/librariesio/release/npm/lit-ntml/latest?style=flat-square\n[ga-ci-badge]: https://img.shields.io/github/actions/workflow/status/motss/lit-ntml/ci.yml?branch=main\u0026label=ci\u0026logo=githubactions\u0026logoColor=white\u0026style=flat-square\n[ga-publish-badge]: https://img.shields.io/github/actions/workflow/status/motss/lit-ntml/publish.yml?branch=main\u0026label=publish\u0026logo=githubactions\u0026logoColor=white\u0026style=flat-square\n[codecov-badge]: https://img.shields.io/codecov/c/github/motss/lit-ntml/main?label=codecov\u0026logo=codecov\u0026style=flat-square\n\n[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ed55bb?style=flat-square\n\n\u003c!-- Links --\u003e\n[buy-me-a-coffee-url]: https://www.buymeacoffee.com/RLmMhgXFb\n[follow-me-url]: https://twitter.com/igarshmyb?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=motss/lit-ntml\n\n[npm-latest-url]: https://www.npmjs.com/package/lit-ntml/v/latest\n[mit-license-url]: https://github.com/motss/lit-ntml/blob/main/LICENSE\n\n[downloads-url]: http://www.npmtrends.com/lit-ntml\n\n[dependencies-url]: https://libraries.io/npm/lit-ntml\n[ga-ci-url]: https://github.com/motss/lit-ntml/actions/workflows/ci.yml?query=branch%3Amain\n[ga-publish-url]: https://github.com/motss/lit-ntml/actions/workflows/publish.yml?query=branch%3Amain\n[codecov-url]: https://app.codecov.io/gh/motss/lit-ntml/tree/main\n\n[coc-url]: https://github.com/motss/lit-ntml/blob/main/code-of-conduct.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmotss%2Flit-ntml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmotss%2Flit-ntml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmotss%2Flit-ntml/lists"}