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.

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 any sequence, iterator, or generator of elements 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 have not 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.

section()> ()

For open tags like <br> and <hr>, you simply do br() and hr().

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.5.0.tar.gz (17.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.5.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: domini-0.5.0.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for domini-0.5.0.tar.gz
Algorithm Hash digest
SHA256 55b29f43f19cd79190a6663d8a5d2f1c8667e317256b134b82488f004fa1bf41
MD5 ea03a0ebdd40c66149fe83deaad7d26a
BLAKE2b-256 007627bdf181b83f5743d5448c606f872c810af58f2017a575f133ccf4abf45b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: domini-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for domini-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87b026e9ab15569ce30836599d3dd4c077a8e140054240a51ff25ef62bbea193
MD5 c217f56632dbc2cdc6e7c0cbfca9ad78
BLAKE2b-256 64f234c9517a8a64cd8a47ac663dd21a358601230446c60029220e4a7adc36f9

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