Open pauleveritt opened 11 months ago
Sorry, just seeing this issue.
So the problem is the use of the extra parentheses, which I attempting to highlight: [html('...') ...]
, it should be [html'...' ...]
Speciifcally the code should be
html'<ul title="{message}">{[html'<li>{name}</li>' for name in names]}</ul>'
which results in what we expect
'<ul title="Hello"><li>World</li><li>Universe</li></ul>'
And to be clear, what does the extra parens result in? It's just a regular string, which is why {name}
is not evaluated:
html('<li>{name}</li>')
results in
'<li>{name}</li>'
This can cause confusion because a tag function takes *args: Chunk|Thunk
(or alternatively, *args: str|tuple
. So it happily takes '<li>{name}</li>'
, and then returns it, since that's valid HTML.
Note that it doesn't like an argument that is not HTML, like html('alice')
reporting
AttributeError: 'str' object has no attribute 'attrs'
So that's invalid HTML, but it should fail deep in the compiler.
I am SOOOOO sorry. This is a cut-and-paste mistake by me. My ViewDOM thing does html('<div/>')
and I've seen it so much, I didn't spot it.
Want to close this? Should I make a ticket for the last point?
Let's keep it open for the following reasons:
This:
...results in: