htmlgo
htmlgo copied to clipboard
Feature request: Disallow tags in invalid places
Hi,
I was able to put a h1 inside a head tag, it would be really good if it could avoid things like this.
html := Html5_(
Head_(
H1_(Text("Test")),
),
Body_(
H1_(Text("Test")),
),
)
Here, the H1 inside the Head tag should make a compilation error, instead it renders the h1 inside the head tag where it's not allowed
Hey DannyJJK - I really like the idea. Similarly, setting invalid attributes on elements should raise compile errors. It seems like the 2 steps necessary to add this feature would be 1) figuring out a nice way to make reflect valid parent-child (or element-attribute) combinations in the type system and 2) get a complete specification of these valid combinations.
I'll keep this request in mind, but won't promise it will be added anytime soon. If you have any suggestions for one of the two steps above, happy to chat them through