Write safer and cleaner HTML using Python
Project description
htmldoom
Write safer and cleaner HTML using Python
Usage
>>> from htmldoom import elements as e >>> >>> e.P(style=e.style(color="red"))("This is a paragraph") <p style="color: 'red';">This is a paragraph</p>
>>> from htmldoom import elements as e >>> from htmldoom.layouts import BaseLayout >>> >>> class MyLayout(BaseLayout): ... @property ... def title(self) -> e.Title: ... return e.Title()(self.data["title"]) ... @property ... def body(self) -> e.Body: ... return e.Body()(f"Welcome {self.data['user']['name']}")... >>> MyLayout({"title": "foo", "user": {"name": "bar"}}) <!DOCTYPE html> <html><head><title>foo</title></head><body>Welcome bar</body></html>
Benchmarks
Very basic benchmark done using this script and IPython
htmldoom
Jinja2
Mako
Chameleon
Conclusion
htmldoom performs best upto a certain number of recursions which is generally high enough. These measurements are very naive and shows very basic information. Some templating engines might have performance optimizations (such caching) enabled by default. However, In case of htmldoom, it's upto to developer (for now) to optimize it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file htmldoom-0.0.10.tar.gz
.
File metadata
- Download URL: htmldoom-0.0.10.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98df347275c2fb7ef0473ae8b7d1a3d6025bcccbcf9cd60f0591a5d8cec9f17c |
|
MD5 | 581d3b72f35053fb6042bd789b80a1b3 |
|
BLAKE2b-256 | 533d0b7e8971083aac2bb42d174793b70bd14821ce6c87fee45f9b44136c86d1 |
File details
Details for the file htmldoom-0.0.10-py3-none-any.whl
.
File metadata
- Download URL: htmldoom-0.0.10-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0db17115a981809a46f7787f116ae2dd891a91a264e2602ff5b6ffa2bd250cfb |
|
MD5 | 2c1442bd481aaffee2a1763682dc7336 |
|
BLAKE2b-256 | 6a46588b12cd568b4275e31994d41d21e32cdcf8051daa74556ae35961681e68 |