{"id":16146528,"url":"https://github.com/voxpelli/async-htm-to-string","last_synced_at":"2025-09-13T00:32:31.439Z","repository":{"id":37201243,"uuid":"308931890","full_name":"voxpelli/async-htm-to-string","owner":"voxpelli","description":"Renders a htm tagged template asyncly into a string","archived":false,"fork":false,"pushed_at":"2025-01-04T19:51:09.000Z","size":119,"stargazers_count":17,"open_issues_count":6,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-04T20:32:52.785Z","etag":null,"topics":["asynciterable","asynciterator","htm","server-side-rendering","ssr","tagged-template-literals","template-literal"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/voxpelli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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},"funding":{"github":["voxpelli"]}},"created_at":"2020-10-31T17:07:39.000Z","updated_at":"2025-01-04T19:50:32.000Z","dependencies_parsed_at":"2023-12-26T01:23:54.914Z","dependency_job_id":"d520dbb5-5c21-4431-a0f4-946e6f81ef19","html_url":"https://github.com/voxpelli/async-htm-to-string","commit_stats":{"total_commits":110,"total_committers":4,"mean_commits":27.5,"dds":"0.30000000000000004","last_synced_commit":"98d14b0afc85e3ec40c763be35700fc34ec38410"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fasync-htm-to-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fasync-htm-to-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fasync-htm-to-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fasync-htm-to-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voxpelli","download_url":"https://codeload.github.com/voxpelli/async-htm-to-string/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232802581,"owners_count":18578685,"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":["asynciterable","asynciterator","htm","server-side-rendering","ssr","tagged-template-literals","template-literal"],"created_at":"2024-10-10T00:20:24.595Z","updated_at":"2025-01-07T00:15:44.602Z","avatar_url":"https://github.com/voxpelli.png","language":"JavaScript","funding_links":["https://github.com/sponsors/voxpelli"],"categories":[],"sub_categories":[],"readme":"# async-htm-to-string\n\nRenders a [`htm`](https://www.npmjs.com/package/htm) tagged template asyncly into a string.\n\n[![npm version](https://img.shields.io/npm/v/async-htm-to-string.svg?style=flat)](https://www.npmjs.com/package/async-htm-to-string)\n[![npm downloads](https://img.shields.io/npm/dm/async-htm-to-string.svg?style=flat)](https://www.npmjs.com/package/async-htm-to-string)\n[![Module type: CJS+ESM](https://img.shields.io/badge/module%20type-cjs%2Besm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)\n[![Types in JS](https://img.shields.io/badge/types_in_js-yes-brightgreen)](https://github.com/voxpelli/types-in-js)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-7fffff?style=flat\u0026labelColor=ff80ff)](https://github.com/neostandard/neostandard)\n[![Follow @voxpelli@mastodon.social](https://img.shields.io/mastodon/follow/109247025527949675?domain=https%3A%2F%2Fmastodon.social\u0026style=social)](https://mastodon.social/@voxpelli)\n\n## Usage\n\n### Simple\n\n```bash\nnpm install async-htm-to-string\n```\n\n```javascript\nconst { html, renderToString } = require('async-htm-to-string');\n\nconst customTag = ({ prefix }, children) =\u003e html`\u003cdiv\u003e${prefix}-${children}\u003c/div\u003e`;\nconst dynamicContent = 'bar';\n// Will equal \"\u003cdiv\u003efoo-bar\u003c/div\u003e\nconst result = await renderToString(html`\u003c${customTag} prefix=\"foo\"\u003e${dynamicContent}\u003c/${customTag}\u003e`);\n```\n\n## API\n\n### `html`\n\nIs `h()` bound to [`htm`](https://www.npmjs.com/package/htm) (`htm.bind(h)`). Used with template literals, like:\n\n```javascript\nconst renderableElement = html`\u003cdiv\u003e${content}\u003c/div\u003e`;\n```\n\n### `rawHtml / rawHtml(rawString)`\n\nIf you need to provide pre-escaped raw HTML content, then you can use `rawHtml` as either a template literal or by calling it with the\n\n```javascript\nconst renderableElement = rawHtml`\u003cdiv\u003e\u0026amp;${'\u0026quot;'}\u003c/div\u003e`;\n```\n\n```javascript\nconst renderableElement = rawHtml('\u003cdiv\u003e\u0026amp;\u003c/div\u003e');\n```\n\nYou can also use the result of any of those `rawHtml` inside `html`, like:\n\n```javascript\nconst renderableElement = html`\u003cdiv\u003e${rawHtml`\u0026amp;`}\u003c/div\u003e`;\n```\n\n### `h(type, props, ...children)`\n\nThe inner method that's `htm` is bound to.\n\n### `render(renderableElement)`\n\nTakes the output from `html` and returns an async iterator that yields the strings as they are rendered\n\n### `renderToString(renderableElement)`\n\nSame as `render()`, but asyncly returns a single string with the fully rendered result, rather than an async iterator.\n\n## Helpers\n\n### `generatorToString(somethingIterable)`\n\nAsyncly loops over an iterable (like eg. an async iterable) and concatenates together the result into a single string that it resolves to. The brains behind `renderToString()`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpelli%2Fasync-htm-to-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoxpelli%2Fasync-htm-to-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpelli%2Fasync-htm-to-string/lists"}