WebHelpers2
WebHelpers2 copied to clipboard
HTML tag c arg escaping content
My understanding is that literal strings should not be escaped at any point. However: HTML.li(c=link_to('something', '#'))
yields literal('<li><a href="#">something</a></li>')
in Python 3 (3.6 to be specific).
The same input in Python 2.7 gives the expected literal(u'<li><a href="#">something</a></li>')
. Also, in Python 3, passing the content without the c kwarg HTML.li(link_to('something', '#'))
gives the expected literal('<li><a href="#">something</a></li>')
.
Literals should never be escaped, and c
should behave exactly as *args
. Write a unit test for the example above. It will presumably fail on Python 3 due to a difference in c
processing. builder.py lines 240-241 (commit ed4a43) appear to convert c
to args
so they're exactly the same, but there may be a subtle difference.
The purpose of c
is to put the tag content after the tag attributes, which is the opposite of Python's positional-argument syntax. It was not anticipated that c
would be used without keyword attributes, or that the value of c
would be literal(s), nevertheless it should handle them properly.