Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/garyvdm/htmlwrite
- Owner: garyvdm
- Created: 2014-12-09T09:14:44.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-03-16T08:34:14.000Z (over 4 years ago)
- Last Synced: 2024-07-17T03:49:10.712Z (4 months ago)
- Language: Python
- Homepage: https://pypi.python.org/pypi/htmlwrite
- Size: 26.4 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.