#106 htmlfill does not support new html5 input types

closed-fixed
nobody
None
5
2011-09-24
2010-07-13
Josh Rosen
No

htmlfill reports "I don't know about this kind of <input>" for all of the new html5 input types. For example,

>>> from formencode import htmlfill
>>> form = '<input type="number" name="quantity">'
>>> defaults = {'quantity': '10'}
>>> htmlfill.render(form, defaults)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/FormEncode-1.2.1-py2.6.egg/formencode/htmlfill.py", line 78, in render
p.feed(form)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/FormEncode-1.2.1-py2.6.egg/formencode/rewritingparser.py", line 36, in feed
HTMLParser.HTMLParser.feed(self, data)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/HTMLParser.py", line 108, in feed
self.goahead(0)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/HTMLParser.py", line 148, in goahead
k = self.parse_starttag(i)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/HTMLParser.py", line 268, in parse_starttag
self.handle_starttag(tag, attrs)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/FormEncode-1.2.1-py2.6.egg/formencode/htmlfill.py", line 273, in handle_starttag
self.handle_input(attrs, startend)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/FormEncode-1.2.1-py2.6.egg/formencode/htmlfill.py", line 413, in handle_input
% (t, self.getpos())
AssertionError: I don't know about this kind of <input>: number (pos: (1, 0))

Discussion

  • Marius Gedminas

    Marius Gedminas - 2010-07-13

    You could pass text_as_default=True to htmlfill.render(), as a workaround.

    I agree that htmlfill ought to know about HTML5.

     
  • Christoph Zwerschke

    • status: open --> closed-fixed
     
  • Christoph Zwerschke

    Fixed in <<changeset 0f82b3ef6c04>>. But as a simple workaround, you can also set text_as_default=True.

     
  • Christoph Zwerschke

    Hm, I always overlook the existing comments. The comment entry field should really be *below* the existing comments, not above them.

     

Log in to post a comment.