Draft attempt at updating self-closing rules#141
Conversation
… instead of self-closing.
|
This should be stacked on #140 |
|
After 140 lands, how would you feel about separating this into two bits: the relaxation behavior, and everything else? Everything else feels like it can land. I like how The relaxation stuff is clearly important! Sheesh. But I also feel like I don't fully understand its implications just yet. This is the kind of "simple" case I have in mind that we want to support: def Vector(children: Template) -> Template:
return t"<svg>{children}</svg>"
html(t"<div><{Vector}><circle/></{Vector}></div>") |
I guess I feel the same about this being ready UNLESS we can't find a suitable answer for the "relaxation" situation. Just to split them we need a what should we do answer. I think there are two options:
"pass-through" -- feels too confusing to me and is something we definitely wouldn't want to commit to
Yes, I think this is a perfect example that boils down to just the stuff that matters. (There might be other permutations of svg/mathml/html but this is the foremost use case in my mind). |
|
First of all: hope you had a fun Fathers' Day! Second of all: I sat uneasy for the better part of the week about whether Maybe I was too willing to conflate the issue in #132 with the overall issue of when self-closing is even allowed. If self-closing is allowed everywhere,
I agree, "reset" seems like the better of the two answers; "pass-through" feels too confusing to me, too. And I doubly agree: neither of them feels particularly great. Which is maybe one of the reasons I started questioning the direction we've been discussing entirely. Maybe "reset" turns out to have a fairly elegant implementation that's also not too horrible from the perspective of error handling. Or... maybe not? |
I did a practice 5K and just about completely exhausted myself. Excercise.. NOT EVEN ONCE!
There are a lot of related but different ideas floating around which makes this situation more confusing than usual. Also there is no great answer (at least so far!). Just to recap here a bit because I went down a rabbit hole on error handling:
I thought of another approach I'm going to put it another issue. ( #142 ) |
|
@ianjosephwilson I've come around to the view that the parser keeping track of namespaces is not the way to go. The Okay to close this PR? |
|
I think we gave it a shot but unless we can think of a better solution you can close this. We need to document the feature matrix of what we accept though and maybe that slash issue... maybe in a docs issue? Just to clarify, you are proposing we return to the way things were "before" revisiting the self-closing? Ie. the cache is back to being namespace unaware as before, drop the I started on that "other" approach I mentioned in the prior comment and it would "mostly" work but its pretty gross and good luck explaining it. It did require back-tracking through closed |
Try to adhere to html5 with these rules:
<tag>or<tag/><tag></tag><tag></tag>or<tag/>Attempt to parallel
ProcessContextin parser initially withParseContext.- context is passed in from processor as each template is parsed
- the parse context now becomes PART of the cache key in addition to template.strings, so a template parsed as "svg" is not the same as a template parsed as "html"
- once the context is in the parser itself it is managed internally as the stack grows and shrinks with
InternalParseContext- parsing components has some complications, see below
Parsing components brings up a complication in that we don't know the children's context when we parse the larger template. So we relax the rules to get through the parsing. Later when the processor is running the actual context can be determined WHEN we parse the template and if it is different the cache will miss, the parsing will re-occur and an error might occur. I think this needs more tests to determine what the drawbacks of this approach are. I think it might make resolving the error messages even that much more complicated but I'm not sure.