@proc/html
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

async html tagged template for rendering on the server.

Basically a tiny wrapper around hyperx and virtual-dom to allow attributes and children to be promises.

Usage

import { html, render } from "@proc/html";

const title = "<Example>";

const someAsyncTask = () => {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve("delayed");
    }, Math.random() * 1000);
  });
};

const template = html`
  <html>
    <body>
      <h1>${title}</h1>
      <p>
        ${someAsyncTask().then(
          text =>
            html`
              it's <strong>${text}</strong>!
            `
        )}
      </p>
    </body>
  </html>
`;

render(template).then(rawHTML => {
  console.log(rawHTML);
});

Readme

Keywords

none

Package Sidebar

Install

npm i @proc/html

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

14.9 kB

Total Files

6

Last publish

Collaborators

  • thechriswalker