8 breaking releases

new 0.9.0 Jan 20, 2025
0.7.0 Jan 17, 2025
0.3.0 Sep 20, 2023
0.1.0 May 29, 2023

#91 in Template engine

Download history 18/week @ 2024-09-30 18/week @ 2024-12-09 223/week @ 2025-01-06 234/week @ 2025-01-13

457 downloads per month

MIT license

52KB
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

~28KB