Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/garyvdm/htmlwrite

Python html writing tool
https://github.com/garyvdm/htmlwrite

Last synced: 3 months ago
JSON representation

Python html writing tool

Awesome Lists containing this project

README

        

`htmlwrite` is a python library for writing html to a file like object, using a pythonic syntax. Use as an alternative to templating engines.

>>> import sys
>>>
>>> from htmlwrite import Writer, Tag
>>>
>>> writer = Writer(sys.stdout)
>>> w = writer.write
>>> c = writer.context
>>>
>>> with c(Tag('html')):
... with c(Tag('body')):
... with c(Tag('div', class_=('foo', ), s_font_weight='bold')):
... w('Hello world ')
... w(Tag('div'), 'ok, bye.')
...



Hello world

ok, bye.