Skip to main content

An intuitive, high performance HTML rendering framework

Project description

htmldoom

An intuitive, high performance HTML rendering framework

PyPI version PyPI version Build Status codecov Code style: black

Usage

A basic tag

>>> from htmldoom import render, elements as e
>>> 
>>> print(render(e.p(style="color='red'")("This is a paragraph")))
<p style="color:'red';">This is a paragraph</p>

A functional style foreach loop with a switch case

>>> from htmldoom import elements as e
>>> from htmldoom import functions as fn
>>> 
>>> tuple(fn.foreach(["good", "bad", "evil"])(
...     lambda x: fn.switch({
...         x == "good": lambda: e.span(style="color: green")(f"this is {x}"),
...         x == "bad": lambda: e.span(style="color: yellow")(f"this is {x}"),
...         x == "evil": lambda: e.span(style="color: red")(f"this is {x}"),
...         fn.Case.DEFAULT: lambda: fn.Error.throw(ValueError(x)),
...     })
... ))
(b'<span style="color: green">this is good</span>',
 b'<span style="color: yellow">this is bad</span>',
 b'<span style="color: red">this is evil</span>')

Find more examples here

Q/A

What is the goal here?

The primary goal is to make writing HTML pages cleaner, easier, safer and intuitive using Python.

What about performance?

Although performance is not the primary goal here, it should not be a roadblock. htmldoom is copying the syntax and some of the rendering properties of elm, an existing fast and purely functional programming language that specializes in rendering HTML in virtual doms. Elm does all the optimisation internally, which I'm believe can be implemented in Python to a great extent.
Furthermore, if we follow the the DOM size recommendations, i.e.

  • less than 1500 nodes total.
  • maximum depth of 32 nodes.
  • no parent node with more than 60 child nodes.
htmldoom should perform really well.

Plugins and ecosystem

  • moodlmth: Convert raw HTML pages into python source code

Contributing

Check out the contributing guidelines.

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

htmldoom-0.6.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

htmldoom-0.6-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file htmldoom-0.6.tar.gz.

File metadata

  • Download URL: htmldoom-0.6.tar.gz
  • Upload date:
  • Size: 7.6 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

Hashes for htmldoom-0.6.tar.gz
Algorithm Hash digest
SHA256 faae10e99282ce1acea39ded43dfca319d14c69d90899ce17d3c88c18bfb36bc
MD5 80c6e9cc2b8fc1e1969ad2404e1b7d3f
BLAKE2b-256 be426e3736952f5362540446bf6be81be74c4416d3b2e56b56ef0efadcc50fdf

See more details on using hashes here.

File details

Details for the file htmldoom-0.6-py3-none-any.whl.

File metadata

  • Download URL: htmldoom-0.6-py3-none-any.whl
  • Upload date:
  • Size: 10.3 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

Hashes for htmldoom-0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0547a5d6700a6dde49f297971a0d3f0b4191b605041f5cd5fca4b73eccc30545
MD5 65d6efcdcd882caad8351aff597ca16e
BLAKE2b-256 6f453cc2e2e36fe780de166a7e00db81ffcd011aa3495616b15bbe34f9d8b5f3

See more details on using hashes here.

Supported by

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