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.9.tar.gz
.
File metadata
- Download URL: htmldoom-0.0.9.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 | 11cc79895b3e1f565bbe1cf90f7eafb07fb9691561d5194397c4aa703928f988 |
|
MD5 | e5f954126fcc4251455515c76d73d129 |
|
BLAKE2b-256 | 2997af6ee5d81fcc28951ca5a94777325e8d5bd6860ff008ca91473d6ba67f01 |
File details
Details for the file htmldoom-0.0.9-py3-none-any.whl
.
File metadata
- Download URL: htmldoom-0.0.9-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 | ad540efa15de11ec00d17b60626265a2df8911717cb3399ba931aaf3397b2821 |
|
MD5 | 24efa33eb265529dbfc0066422c06b3b |
|
BLAKE2b-256 | f67721486b901a4d03607a4a23ee67419e748cce716768e616d4e2d9130647b8 |