Skip to main content

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, there are a few different methods you can use. The content can be either an iterable or a lone element. These elements can be either other tags or plain strings.

  • add adds the children to the current object.
  • > returns a shallow copy of the element with the children added.
  • >> returns a deep copy of the element with the 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

domini-0.10.0.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

domini-0.10.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file domini-0.10.0.tar.gz.

File metadata

  • Download URL: domini-0.10.0.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for domini-0.10.0.tar.gz
Algorithm Hash digest
SHA256 eef2b80b39e6fcf83e2e706e3101547c63781e51bb6795d87184b6c43bc8f045
MD5 a1f1cd7b4e7a0ce4b69c8c22e52f2121
BLAKE2b-256 0b2322578a3cd71410e14d0274c3b960da9b51174a941325f69fce3a1036052c

See more details on using hashes here.

File details

Details for the file domini-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: domini-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for domini-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19c3b8400f3e91f1dd94bc655425809ee8f8aafac6fafc906a0d60e217dc07c9
MD5 a547825ce07953215dfba8e493f8d372
BLAKE2b-256 a5b5ae0ad22945b73e6552de1772cffeb1fe2a89716becc8f12f296429fce14a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page