1.2.2 • Published 10 months ago

@tusent.io/mallet v1.2.2

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

mallet

import { createView } from "mallet";
import { minify } from "html-minifier";
import escapeHTML from "escape-html";

const html = createView((text) => minify(text, { collapseWhitespace: true }));

html`
    <div>
        <h1>Hello World</h1>
        <p>${"Hello World"}</p>
        <p>${escapeHTML("<p>Hello World</p>")}</p>

        ${() => {
            for (let i = 0; i < 10; i++) {
                // This works!
                html`<p>${i}</p>`;

                // This also works!
                html("<p>" + i + "</p>");
            }
        }}

        ${() => {
            let text = "";
            for (let i = 0; i < 10; i++) {
                text += `<p>${i}</p>`;
            }

            // This works!
            return text;
        }}

        ${() => {
            html`<p>This will not be included.</p>`;

            // Returns are prioritized.
            return "<p>This will be included.</p>";
        }}

        ${html`
            <p>This does NOT work and will cause infinite recursion!</p>
        `}
    </div>
`;

console.log(html.toString());
1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.1

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago