1.0.3 • Published 2 years ago

@hedia/html v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@hedia/html

Install

$ npm install @hedia/html -E

Usage

import { attr, comment, document, render } from "@hedia/html";
import { a, body, h1, head, html, img, meta, p, title } from "@hedia/html/elements";
import { content, name, style } from "@hedia/html/attributes";

render(
  document(
    html(
      lang("en"),
      comment("head --"),
      head(
        title("HTML | Hedia"),
        meta(
          name("description"),
          content("Hedia HTML Renderer."),
        ),
        meta(
          name("keywords"),
          content("hedia,html,rendering."),
        ),
      ),
      body(
        h1("HTML", isItMonday() && p("It is monday")),
        p(style("font-weight: bold"), "Hedia HTML Renderer."),
        img(
          src(
            "https://www.hedia.co/wp-content/uploads/2017/03/hedia_blue.png",
          ),
        ),
        a(href("https://hedia.co/"), "Hedia"),
      ),
    ),
  ),
);

Outputs:

<!DOCTYPE html>
<html lang="en">

<head>
    <!--head-->
    <title>HTML | Hedia</title>
    <meta name="description" content="Hedia HTML Renderer.">
    <meta name="keywords" content="hedia,html,rendering.">
</head>

<body>
    <h1>HTML</h1>
    <p style="font-weight: bold">Hedia HTML Renderer.</p>
    <img src="https://www.hedia.co/wp-content/uploads/2017/03/hedia_blue.png">
    <a href="https://hedia.co/">Hedia</a>
</body>

</html>

API

renderToBuffer

Renders the Document, Element or Text node to a Buffer with UTF-8 encoding.

import { attr, document, renderToBuffer } from "@hedia/html";
import { body, head, html, } from "@hedia/html/elements";

const buffer = renderToBuffer(
  document(
    html(
      head(),
      body(),
    ),
  ),
);

renderToReadable

Renders the Document, Element or Text node to a Readable 64kb at a time.

import { document, renderToReadable } from "@hedia/html";
import { body, head, html, } from "@hedia/html/elements";

const readable = renderToReadable(
  document(
    html(
      head(),
      body(),
    ),
  ),
);

process.stdout.pipe(readable);

Build

$ npm run build

Test

$ npm test
1.0.3

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.1-0

3 years ago

1.0.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago