0.2.0 • Published 4 years ago

@proc/html v0.2.0

Weekly downloads
4
License
MIT
Repository
-
Last release
4 years ago

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);
});
0.2.0

4 years ago

0.1.35

5 years ago

0.1.28

5 years ago