DOM Tree
Simple API to create DOM trees in Python. A bit like JSX, but with native Python syntax.
Aims to include useful autocompletion. Currently this works for SVGs.
Basic example
from domtree.svg import *
print(
svg(viewBox="0 0 100 100", xmlns="http://www.w3.org/2000/svg")(
circle(cx=50, cy=50, r=50),
)
)
# <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
# <circle cx="50" cy="50" r="50" />
# </svg>
Generated content
from domtree.svg import *
print(
svg(
circle(x=0, y=i * 10, r=2) for i in range(5)
)
)
# <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
# <circle x="0" y="0" r="2" />
# <circle x="0" y="10" r="2" />
# <circle x="0" y="20" r="2" />
# <circle x="0" y="30" r="2" />
# <circle x="0" y="40" r="2" />
# </svg>
Custom nodes
from domtree import Node
ul = Node("ul")
li = Node("li")
print(
ul(
li("First item"),
li(className="second")("Second item")
)
)
# <ul>
# <li>
# First item
# </li>
# <li class="second">
# Second item
# </li>
# </ul>
Autocomplete
Metadata
Release files for domtree 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| domtree-0.0.5.tar.gz | 240.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| domtree-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 262.4 kB
Release files / domtree-0.0.5.tar.gz
| Download URL | domtree-0.0.5.tar.gz |
|---|---|
| Size | 240.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b33fe5a800d8a261594584b59aead58f984ea0b1f9b61eeed787a78bb01952c1
|
|
BLAKE2b-256 checksum How to use checksums |
edff8b5bcf64793ad3a8f1bd6fa7a8199f5c374db72a48e7a68fdc4101274366
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Release files / domtree-0.0.5-py3-none-any.whl
| Download URL | domtree-0.0.5-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3eeb82846eb42cdc21ce0fa3a84195fec8cadd91ebff4a47885982676a2d10de
|
|
BLAKE2b-256 checksum How to use checksums |
afaf75449470c04bfb7d39e3287ed90f0e52633fac9070cc9c00c9290a53aa92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|