Skip to content

Not Another HTML Generator

Carl Smith edited this page Jun 10, 2018 · 16 revisions

HTME offers four main advantages to Full Stack Python devs (in no particular order)...

  • HTME is not a new language.

HTME is a domain specific dialect of Python, meaning you have the full power of Python available. For example, HTME is (naturally) object oriented, and we have add a few extra conveniences, so you can easily extend an element (or the engine) by simply subclassing it and weaving in whatever functionality makes your life easier.

  • But HTME is a new domain specific dialect.

The library implements a complete collection of custom element classes (covering HTML5, SVG and MathML) that implement flexible signatures and overloaded operators that allow you to express and mutate DOM trees in an elegant and intuitive way.

  • No matter how good your dialect is, boilerplate is still boilerplate.

A unique and obvious advantage that HTME offers over other libraries is that it generates most of the document from user friendly attributes (like title, author and scale). You only need to build the guts of the BODY element (the tree) manually.

  • Stay DRY and reuse state across similar documents and DOM fragments.

A demonstrated in the Complete Example, you can freeze the current state of the engine or any element as a string, allowing you to reuse the state. For example, you could set up the engine with some state that is common to a number of webpages, and then in a loop, mutate the details that change from page to page, freezing the current state at the end of each iteration. You could then simply import the engine instance from the module you defined your webpages in, making all of them readily available (with an optional post-processor (based on str.format) for good measure).

Clone this wiki locally