Registry / web-framework / htmlbuilder

htmlbuilder

JSON →
library1.0.0pypypi✓ verified 80d ago

A Python library for building HTML programmatically, providing a Pythonic way to construct HTML elements and attributes. The current stable version is 1.0.0, released on 2022-08-03. The project appears to be in maintenance mode with no recent updates.

pip install htmlbuilder
INSTALL
IMPORT
SIG · HTMLBUILDER
H
htmlbuilder
web-frameworkpythonv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

htmlBuilder
import htmlBuilder
from htmlbuilder import tags

Construct a simple HTML document with a heading and a paragraph.

from htmlbuilder.tags import html, head, body, h1, p from htmlbuilder.attributes import Class, Id doc = html( head(), body( h1('Hello, world!', Class('main-title'), Id('title')), p('This is a paragraph.', Class('content')) ) ) print(str(doc))
Debug
Known issues
gotchaAll tag functions return a Node object, not a string. You must call str() or use render() to get the HTML string.
fix
Use str(node) or node.render() to produce the HTML output.
affects: all
deprecatedThe library has not been updated since 2022 and may not support newer Python features or fix bugs.
fix
Consider using an alternative like dominate or lxml.html if you need active maintenance.
affects: 1.0.0
gotchaAttributes must be passed as keyword arguments or using attribute classes; positional attribute strings are not supported.
fix
Use Class('value') or Id('value') from htmlbuilder.attributes for class and id.
affects: all
Upgrade
Version history
1.0.0latest on PyPI · released Mar 2, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
htmlbuilder — pip install htmlbuilder · libregistry