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 class when all optional classes are omitted #424

Open
SenojLuap opened this issue Feb 26, 2024 · 1 comment
Open

Empty class when all optional classes are omitted #424

SenojLuap opened this issue Feb 26, 2024 · 1 comment

Comments

@SenojLuap
Copy link
Contributor

This may be a 'working as intended' situation, but I thought I'd raise the issue in case it's not:

Currently, if you're applying a class to an element optionally, but the condition is falsey, maud still generates a 'class' attribute, but with an empty class list.

Ex.

use maud::{html, Render};
fn main() {
    let demo_output = html! {
      p .someClass[false] {
        "Lorem Ipsum"
      }
    }
    .render();
    println!("Generated html: {}", demo_output.0);
}

Output: Generated html: <p class="">Lorem Ipsum</p>

Note that a 'class' attribute is generated, even though it isn't needed.

Definitely not a huge deal, but it would be nice to keep the HTML trim where possible.

@SenojLuap
Copy link
Contributor Author

Also: I'm not opposed to putting in PR for this. I just wasn't sure whether this was an intentional 'feature' or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant