[Python-ideas] HTML Wrapper

Vlad Tudorache tudorache.vlad at gmail.com
Thu Mar 14 17:00:03 EDT 2019


Hello,

I'd like to know if there is a basic HTML wrapper for Python, like
TextWrapper but allowing the generation of HTML from strings or iterables
of strings. Like:

make_select = HTMLWrapper(tag='select class="eggs"', indent='  ')
make_option = HTMLWrapper(tag='option')

Applying this like:

s = make_select([make_option('Option %d' % (i + 1), \
    escape=False, strip=False) for i in range(3)])

should return s like (when printed):

<select class="eggs">
  <option>Option 1</option>
  <option>Option 2</option>
  <option>Option 3</option>
</select>

Vlad Tudorache
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190314/79f29638/attachment-0001.html>


More information about the Python-ideas mailing list