python classes to create accessible HTML elements and documents
Project description
domible
Domible is a set of Python classes used to generate HTML documents and elements of arbitrary complexity. The basic idea behind domible is fairly simple, HTML elements are represented as Python objects. When an element object is evaluated, it renders the text of the HTML element. Objects can contain other element objects which will also evaluate to text when the containing object is evaluated. See below for a basic example.
Origin Story
domible is an evolution of the pymenable package which is deprecated.
Instead of using jinja templates for the basic structure of the HTML document, a root class, Html, generates the <html> element with Head and Body classes generating the <head> and <body> elements. Elements can be added to the head and body to generate HTML documents of arbitrary complexity.
I decided pymenable was too complicated using jinja templates (e.g., having to manage extra resources and learn to use jinja).
I'm not disparaging jinja, it's an awesome tool. I think it's easier though to use Python classes to create the root element as well as all the other elements for the HTML document.
Plus I wanted to change the name.
Installation
To install the domible package (which includes a simple starter script), run:
pip install domible
Along with the domible package is a script, distarter
to serve as an example of how to use domible. After you pip install domible, you should be able to run distarter
from the command line. Running it should result in a very simple web page shown in your default browser. See below for how to find the code for distarter
.
Domible has an optional command line interface (dicli
) to show some examples. To install dicli
along with domible, and be able to run dicli
from the command line, install domible with:
pip install domible[dicli]
dicli
is built using the Python package
typer.
Instead of documenting dicli
here, I'll keep the internal typer supported help current.
For details on how to use dicli
, run:
dicli --help
Usage
At some point there will be really cool examples here using Jupyter Notebooks. Until then, the code from distarter
will serve as a starting point.
To get the code for distarter
, look in the site-packages, where you pip installed domible, for the distarter package.
And/or, you can clone the domible repo and look in domible/src/distarter/main.py
.
Contributing
Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.
License
domible
was created by Joel Dodson. It is licensed under the terms of the MIT license.
Credits
domible
was created with
cookiecutter
and the
py-pkgs-cookiecutter
template.
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 domible-0.1.2.tar.gz
.
File metadata
- Download URL: domible-0.1.2.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.11.2 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e323fc3b3ef8397bedf873521fa80c30a747e331864f1afa497db06333ad02e |
|
MD5 | dfe17d4cdfc91945dec80a354f1f7c12 |
|
BLAKE2b-256 | 751a4455858182a15f0eead6fd139291ed8894e814160aa0d0e9fabd03f5ad79 |
File details
Details for the file domible-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: domible-0.1.2-py3-none-any.whl
- Upload date:
- Size: 26.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.11.2 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c26b259bdb4dbdc3136d2b014c9e31ac91cf51c1f32e86062d47ef2d1604a6d |
|
MD5 | c595a220ce3b523d6ca3e27e1a9888f3 |
|
BLAKE2b-256 | 6259e1e705c76085f937ab70318965e777b9ed1710d3158f8f9752ad7b544948 |