7 releases (breaking)

new 0.7.0 Jan 17, 2025
0.6.0 Jan 16, 2025
0.5.0 Jan 10, 2025
0.4.0 Jan 10, 2025
0.1.0 May 29, 2023

#100 in Template engine

Download history 12/week @ 2024-09-25 6/week @ 2024-10-02 6/week @ 2024-12-04 12/week @ 2024-12-11 240/week @ 2025-01-08

240 downloads per month

MIT license

51KB
1.5K SLoC

html-string

A component-oriented html preprocessor

If you've ever wished to compose HTML fragments, this is the library for you.

Create components ...

index.html

<html>
    A special <hs:include src="link.html" href="http://example.org">link</hs:include>
</html>

link.html

<a href="{{ href }}">{{ ... }}</a>

... layouts ...

index.html

<hs:include src="layout.html" title="My Page">
    <h1>My Page</h1>
</hs:include>

layout.html

<!doctype html>
<html>
    <head>
        <title>{{ title }}</title>
    </head>
    <body>
        {{ ... }}
    </body>
</html>

...i cannot believe it's not HTML!

index.html

<hs:let author="Me">
    <div> Author: {{ author }}</div>
</hs:let>

Prior art

Dependencies

~1.7–2.4MB
~41K SLoC