You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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};fnmain(){let demo_output = html!{
p .someClass[false]{"Lorem Ipsum"}}.render();println!("Generated html: {}", demo_output.0);}
I came across this situation and didn't want the empty class="" either. I worked around it by turning the class attribute into an "optional attribute." It's now class=[class] where class is a Some/None value I assigned above/outside the html! {}.
Yeah, the current behavior isn't ideal but it's hard to do a clean fix. Consider when there's more than one class – now you need to check that all classes are omitted before removing the attribute. Not to mention, some of the classes might be non-optional too.
I remember there's a related issue about extra spaces, and a complete solution should fix that as well.
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.
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.
The text was updated successfully, but these errors were encountered: