fasthtml icon indicating copy to clipboard operation
fasthtml copied to clipboard

[BUG] Incorrect property generated for Label("name", for_="test")

Open cmhauser opened this issue 2 years ago • 3 comments

Describe the bug A clear and concise description of what the bug is. Label("name", for_="test") generates: <label for-="test">name</label> It should generate: <label for="test">name</label>

Minimal Reproducible Example Provide a minimal code snippet that reproduces the issue. This is crucial for us to understand and fix the bug quickly.

# Your code here
from fasthtml.common import FastHTML, serve, Label

app = FastHTML()

@app.route("/", methods=["GET"])
def home():
    return Label("test_label", for_="test")

serve()

Expected behavior A clear and concise description of what you expected to happen. The generated property should be "for", not "for-".

Environment Information Please provide the following version information:

  • fastlite version: 0.0.9
  • fastcore version: 1.7.1
  • fasthtml version: 0.4.3

Confirmation Please confirm the following:

  • [ x] I have read the FAQ (https://docs.fastht.ml/explains/faq.html)
  • [ x] I have provided a minimal reproducible example
  • [ x] I have included the versions of fastlite, fastcore, and fasthtml
  • [ x] I understand that this is a volunteer open source project with no commercial support.

Additional context Add any other context about the problem here.

Screenshots If applicable, add screenshots to help explain your problem.

cmhauser avatar Aug 17 '24 21:08 cmhauser

Apparently, the "for_" property in the examples repo doesn't work, but "_for" does.

cmhauser avatar Aug 17 '24 22:08 cmhauser

Thanks _for works for me. Is there a reason why it is not just for?

I think for_ should be removed and _for be rename to for.

wohltat avatar Oct 11 '24 23:10 wohltat

Ok i see now, it is because of the python keywords for.

Something similar with type in the Input / <input> tag. But in the case of 'type, not only does the parameter _typeproduce valid HTML, also there is atypeparameter that works. The difference is thattype` is not a keyword but a built-in function.

But in both cases for_ and type_ invalid HTML code is produced, so i would see this as a bug.

wohltat avatar Oct 11 '24 23:10 wohltat