Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/skitschy/pyHTML5builder


https://github.com/skitschy/pyHTML5builder

Last synced: 7 days ago
JSON representation

Awesome Lists containing this project

README

        

# HTML5Builder

HTML5Builder is a Python module
for simply generating strings of HTML5 documents and document fragments.

## Requirement

* Python 2.7 or above

## Installation

```sh
pip install html5builder
```

## Basic Usage

```python
>>> from html5builder import HTML5Builder
>>> tag = HTML5Builder()
>>> img = tag.img(src='image.jpg')
>>> str(img)
''
>>> anchor = tag.a([img, 'link'], cls='link', href='target.html')
>>> str(anchor)
'link'
>>> div = tag.div()
>>> div.child.append(anchor)
>>> str(div)
'

link
'
>>> doc = tag.html([tag.head(''), tag.body('')], lang='ja')
>>> str(tag.doctype + str(doc))
''
```

## Documentation

Documentation is [available online](https://pyhtml5builder.readthedocs.io/).