Skip to main content

Library for rendering HTML in Python

Project description

Fude (筆) is a library for representing HTML in Python. It uses Lists to represent elements, and Dicts to represent an element’s attributes.

Fude is inspired by Hiccup


Here is a basic example of Fude syntax:

>>> fude.html('text')

>>> fude.html(['tag'])
'<tag />'

>>> fude.html(['div', 'bar'])

>>> fude.html(['span', {'class': 'foo'}, 'bar'])
'<span class="foo">bar</span>'

>>> fude.html(['div', 'bar', ['span', 'baz'], ['span', 'bang']])

>>> fude.html(['div', 'bar', [['span', 'baz'], ['span', 'bang']]])

The first element of the List is used as the element name. The second attribute can optionally be a Dict, in which case it is used to supply the element’s attributes. Every other element is considered part of the tag’s body.

And provides a CSS-like shortcut for denoting id and class attributes:

>>> fude.html(['', 'bang'])
'<div class="bar baz" id="foo">bang</div>'

>>> fude.html(['', 'bang'])
'<div class="bar baz" id="foo">bang</div>'

If the body of the element is a List, its contents will be expanded out into the element body. This makes working with functions like map and List comprehensions:

>>> fude.html(['ul', [['li', x] for x in range(1, 4)]])

Project details

Release history Release notifications

This version
History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
fude-1.0.1.tar.gz (2.3 kB) Copy SHA256 hash SHA256 Source None Dec 16, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page