Create HTML documents using Pythonic syntax that mimics the real deal.
Project description
Domini
A small, simple package for generating HTML documents. The syntax aims to immitate HTML as closely as possible for legibility and easy of use.
Index
Attributes
Attributes without a value are entered as positional arguments.
Attributes with a value are entered as keyword arguments.
To specify attributes that collide with reserved Python keywords, append an underscore and it will be removed.
Python
from domini.html import dialog
dialog('open', class_='mydialog')
HTML
<dialog open class='mydialog'>
Content
To add children to an element, you can use either the add
method or the short-hand greater-than operator. The right-hand side can be either an iterable or a lone element. These elements can be either other tags or plain strings.
NOTE: add
does add them to the current object. >
returns a new, identical element with those children added.
ul(class_='todo')> (
li()> 'Buy a fruit basket.',
li()> (
'Read ', a(href='https://wikipedia.org/')> 'Wikipedia',
' to learn more about things you may not have otherwise cared about.',
),
)
Closing tags
A tag is only closed if content is provided. E.g. <p></p>
as opposed to <p>
. This can be an empty tuple.
p()> ()
For open tags like <br>
and <hr>
, you simply do br()
and hr()
.
Extras
These are small, miscellaneous additions that can be useful but don't really serve any wider purpose within the context of the package itself. Though this might change in the future.
Event attributes
Enumerators for event attributes are available at domini.html.events
. You can either use Event
, which contains all different event attributes in one, or use an enumerator for a specific category of events.
from domini.html.events import (
# These are the categories.
WindowEvent, FormEvent, KeyboardEvent,
MouseEvent, DragEvent, ClipboardEvent,
MediaEvent, MiscEvent,
)
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 domini-0.8.1.tar.gz
.
File metadata
- Download URL: domini-0.8.1.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ec53270361af55db7f1e2738b37f4ea28eb69eeff632dd79bc3a4746d6c29ee |
|
MD5 | 69cdbe463827c264442014dca510e5af |
|
BLAKE2b-256 | fd4c4e7602936520dd1b923d9fe6a0b0786f565f325d0e90d940c74e49a9c4f6 |
File details
Details for the file domini-0.8.1-py3-none-any.whl
.
File metadata
- Download URL: domini-0.8.1-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7420a03433a581245889d872156f4d69fbe39208666ee80472252e5482a563fb |
|
MD5 | ca406b6f9b5e7c21c46d9b96284394d3 |
|
BLAKE2b-256 | be3e6cf0fd84e1b6ab74ae722c2ed817008ce46b76720d44d38d23cf171f8b7a |