0.0.8 • Published 10 months ago

html-tagged v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

html-tagged

A SSR template library that expands custom elements. Inspired by @enhance/ssr.

Usage

import { attr, html } from "html-tagged";
import { renderToString } from "html-tagged/server";

const elements = {
  "my-element": ({ attrs }) =>
    html`<div class="my-element" data-name=${attr(attrs.name)}>
			<slot></slot>
		</div>`,
};

const template = html`<my-element name="test">Hello World!</my-element>`;
const htmlString = renderToString(template, { elements });
console.log(htmlString);

will output:

<my-element name="test">
	<div class="my-element" data-name="test">Hello World!</div>
</my-element>

Performance

The performance mainly comes from the fact this library does not fully parse the input HTML, but instead parses just what's needed for the functionality this library provides. This means that the library is not a full HTML parser, and it will not be able to parse HTML that is not valid for the functionality this library provides.

For a basic "hello world" page:

LibraryOps/sec
@enhance/ssr64867
html-tagged256122

For the Oven-sh's Bun HUGE README (7630 lines):

LibraryOps/sec
@enhance/ssr47
html-tagged306

Development

Testing in Deno can be ran in a single pass with:

deno test -A

Or in watch mode with:

deno test -A --watch

Format code with:

deno task format

Typecheck / lint code with:

deno task check

Contributing Changes

Install CLI:

npm i -g @changesets/cli

Generate changeset:

npx changeset
0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

11 months ago

0.0.3

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago