Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty tags using semicolons should create closing tags for non-void elements #432

Open
twynb opened this issue Jul 1, 2024 · 0 comments
Labels
context aware escaping This feature depends on Maud treating certain elements and attributes in a special way

Comments

@twynb
Copy link

twynb commented Jul 1, 2024

Take this example code:

html! {
    footer {
        div class="nav-padding";
        div class="nav-item" { "example1" }
        div class="nav-item" { "example2" }
        div class="nav-item" { "example3" }
        div class="nav-padding";
    }
}

I'd expect the divs closed by semicolons to become empty divs:

<footer>
    <div class="nav-padding"></div>
    <div class="nav-item">example1</div>
    <div class="nav-item">example2</div>
    <div class="nav-item">example3</div>
    <div class="nav-padding"></div>
</footer>

The actual output is (with whitespace added for readability):

<footer>
    <div class="nav-padding">
        <div class="nav-item">example1</div>
        <div class="nav-item">example2</div>
        <div class="nav-item">example3</div>
        <div class="nav-padding">
</footer>

This matches the behaviour documented in Elements and attributes, only creating an opening tag (because that works for <br> tags), but is a needless pitfall.

My suggestion would be to either insert a closing tag for tags that need one (like <div>) or to have this throw an error within the macro - since you can't manually close a div tag opened using div;, this always leads to invalid/broken HTML.

@lambda-fairy lambda-fairy added the context aware escaping This feature depends on Maud treating certain elements and attributes in a special way label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context aware escaping This feature depends on Maud treating certain elements and attributes in a special way
Projects
None yet
Development

No branches or pull requests

2 participants