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

HTML Templates can't emit attributes without values #2963

Closed
drue opened this issue Jul 14, 2024 · 5 comments · Fixed by #2973
Closed

HTML Templates can't emit attributes without values #2963

drue opened this issue Jul 14, 2024 · 5 comments · Fixed by #2973
Labels
💎 Bounty bug Something isn't working

Comments

@drue
Copy link

drue commented Jul 14, 2024

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>

@drue drue added the bug Something isn't working label Jul 14, 2024
jgoday added a commit to jgoday/zio-http that referenced this issue Jul 20, 2024
@jdegoes
Copy link
Member

jdegoes commented Jul 30, 2024

/bounty $150

cc @jgoday if you want to claim the bounty.

Copy link

algora-pbc bot commented Jul 30, 2024

💎 $150 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #2963 with your implementation plan
  2. Submit work: Create a pull request including /claim #2963 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio-http!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @jgoday Jul 30, 2024, 7:35:58 PM #2973

@jgoday
Copy link
Contributor

jgoday commented Jul 30, 2024

/attempt #2963

Added PartialBooleanAttribute, so we can use boolean attributes without specifying a value (optionally).

input(typeAttr := "text", requiredAttr)
input(typeAttr := "text", requiredAttr := false)

Copy link

algora-pbc bot commented Jul 30, 2024

💡 @jgoday submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Copy link

algora-pbc bot commented Aug 2, 2024

@jgoday: You've been awarded a $150 bounty by ZIO! 👉 Complete your Algora onboarding to collect the bounty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Bounty bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants