0.16.10 • Published 2 years ago

complate-stream v0.16.10

Weekly downloads
109
License
Apache-2.0
Repository
github
Last release
2 years ago

complate-stream

complate's core library for rendering HTML

package version build status Greenkeeper badge

How It Works

At the core of complate-stream lies generateHTML, an implementation of the signature expected by JSX (as pioneered by React). When invoked, that function returns an "element generator"; a function serving as placeholder for the HTML element to be generated:

generateHTML("html", { lang: "en" },
        generateHTML("body", { id: "top" },
                generateHTML("h1", null, "hello world"),
                generateHTML("p", null, "lorem ipsum")));

This indirection is necessary primarily to ensure proper order and nesting, as function arguments are evaluated before the surrounding invocation – otherwise the code above would emit <h1> and <p> before the <body> and <html> elements.

Thus the example above returns a hierarchy of element generators, encapsulated by a single element generator at the root, which upon invocation writes HTML to the stream object being passed in:

let element = generateHTML(…);
element(stream, …);

(stream is expected to support the methods #write, #writeln and #flush; see BufferedStream for a sample implementation).

With our example, this should result in the following string being emitted:

<html lang="en"><body id="top"><h1>hello world</h1><p>lorem ipsum</p></body></html>
0.16.10

2 years ago

0.16.9

5 years ago

0.16.8

5 years ago

0.16.7

5 years ago

0.16.6

5 years ago

0.16.5

6 years ago

0.16.4

6 years ago

0.16.3

6 years ago

0.16.2

6 years ago

0.16.1

6 years ago

0.16.0

6 years ago

0.15.0

6 years ago

0.14.2

6 years ago

0.14.1

6 years ago

0.14.0

7 years ago

0.13.1

7 years ago

0.13.0

7 years ago

0.12.4

7 years ago

0.12.3

7 years ago

0.12.2

7 years ago

0.12.1

7 years ago

0.12.0

7 years ago

0.11.0

7 years ago

0.10.0

7 years ago

0.9.9

7 years ago

0.9.8

7 years ago

0.9.7

7 years ago

0.9.6

7 years ago

0.9.5

7 years ago

0.9.4

7 years ago

0.9.3

7 years ago

0.9.2

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago