Transpile TOML into clean HTML... Because that's clearly what the world needs right now.
web4 is a small utility that lets you write HTML using TOML.
It's a fun and minimal declarative system for generating HTML documents
with structure and attributes defined in simple .toml files.
Think of it like a hand-crafted static templating engine—except your "template" is a TOML config, and the output is HTML5.
- Write HTML in TOML
- Nest tags using
children = [...] - Add attributes (
id,class, etc.) as TOML key-value pairs - Live preview with
--serveand--watch - Minimal dependencies and zero JavaScript required
pip install -r requirements.txtRequires Python 3.10+
python web4.py FILE.toml [--serve] [--watch]
python web4.py --man # view manpage-style help| Flag | Description |
|---|---|
--serve |
Launches a local server at localhost:8080 |
--watch |
Rebuilds the HTML whenever the TOML file changes |
--man |
Displays help in a manpage-like format |
- A
[root]section with achildren = [...]key defining the root elements.
Each TOML section becomes an HTML tag:
[root]
children = ["html"]
[html]
children = ["head", "body"]
[head]
children = ["title"]
[title]
children = ["Hello, world!"]
[body]
children = ["p"]
[p]
children = ["Welcome to ", "strong", "!"]
[strong]
children = ["web4"]Generates:
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<p>Welcome to <strong>web4</strong>!</p>
</body>
</html>["div#main"] # TOML limitations require us to use quotes
class = "container"
children = ["p"]This becomes:
<div id="main" class="container">
<p>...</p>
</div>If a section name is a self-closing/void element (like
img, meta, br, etc.), and it has no children, it is
rendered like this:
[img]
src = "cat.jpg"
alt = "A cute cat"Output:
<img src="cat.jpg" alt="A cute cat" />*.toml— Input files*.html— Output files (same base name)
Let's just say that the license is too much for you to handle. I can't even tell you anything about it. It's because of one of the clauses in the license.
