-
Notifications
You must be signed in to change notification settings - Fork 386
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
HTML Templates can't emit attributes without values #2963
Comments
/bounty $150 cc @jgoday if you want to claim the bounty. |
💎 $150 bounty • ZIOSteps to solve:
Thank you for contributing to zio/zio-http! Add a bounty • Share on socials
|
/attempt #2963 Added PartialBooleanAttribute, so we can use boolean attributes without specifying a value (optionally). input(typeAttr := "text", requiredAttr)
input(typeAttr := "text", requiredAttr := false) Options |
💡 @jgoday submitted a pull request that claims the bounty. You can visit your bounty board to reward. |
@jgoday: You've been awarded a $150 bounty by ZIO! 👉 Complete your Algora onboarding to collect the bounty. |
Describe the bug
Some HTML attributes, e.g.
required
on inputs, are boolean and do not have a value and should be rendered without an equals sign or value like this:<input name="email" required>
see: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required
In Zio HTTP Templates, however, the
required
attribute is the same as all of the other attributes and takes a string value so it always emits an equals and quotes:<input name="email" required="">
which doesn't work in the browser I tried.There are probably other HTML attributes like this and I know some popular front end libs/frameworks rely on these types of boolean attributes.
In Scalatags an empty string will render the attribute without equals or the value so maybe thats how you want to fix this, it certainly the easiest way to do so.
To Reproduce
render a template like
input(nameAttr:="email", requiredAttr:="")
Expected behaviour
output
<input name="email" required>
The text was updated successfully, but these errors were encountered: