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

How to make an optional empty attribute? #327

Closed
Riateche opened this issue Jan 1, 2022 · 2 comments
Closed

How to make an optional empty attribute? #327

Riateche opened this issue Jan 1, 2022 · 2 comments

Comments

@Riateche
Copy link

Riateche commented Jan 1, 2022

I need something like this:

input type="radio" name="f" value="a" checked=(value == 'a');
input type="radio" name="f" value="b" checked=(value == 'b');

This doesn't work because it just generates checked="true" or checked="false". I can work around it like this:

input type="radio" name="f" value="a" checked=[if value == 'a' { Some("") } else { None }];

It generates checked="" if the value matches and nothing otherwise, so it technically works, but it's inconvenient and it would be cleaner to generate an empty attribute.

It would be nice if checked=[value == 'a'] was rendered to checked or nothing.

@lambda-fairy
Copy link
Owner

Hi @Riateche, sorry for the delay 😄

Does this work?

input type="radio" name="f" value="a" checked[value == 'a'];

i.e. remove the = from checked.


On that note: I notice that the optional attributes section is on a different page to the other splices and toggles. I see how that can be confusing. So I'm happy to accept a PR that moves them together.

@lambda-fairy
Copy link
Owner

So I'm happy to accept a PR that moves them together.

#369

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

No branches or pull requests

2 participants