utkarshkukreti / markup.rs

A blazing fast, type-safe template engine for Rust.
Apache License 2.0
350 stars 14 forks source link

Correctly render void elements #38

Open Kijewski opened 7 months ago

Kijewski commented 7 months ago

A void element is an HTML element that cannot have any children. In XML you'd use such an element like <br />.

HTML5 is very lenient, in that you don't have to write the trailing slash. A correctly implemented HTML parser knows which elements are void elements, and it closes the element automagically for you. The parser even "corrects" an input like a<br></br>b to a<br /><br />b for you, which might not be desirable.

If you want to render SVG, XHTML, or other more strict XML applications, you have to close void elements correctly: <br />, NOT <br> or <br></br>.

This PR adds the missing slash to generated void elements, so markup can be used to render e.g. SVG files.

Kijewski commented 7 months ago

Can you please restart the checks? It looks like the runner had a problem, not the code.

Kijewski commented 7 months ago

So, 3 out of 4 commits are now unrelated to the title of the PR. Should I move them into a new PR, or do you not mind?