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

[BUG] Auto-rewriting of routes to paths changes hx-put to hx-post #617

Open
4 tasks done
benbc opened this issue Dec 30, 2024 · 0 comments
Open
4 tasks done

[BUG] Auto-rewriting of routes to paths changes hx-put to hx-post #617

benbc opened this issue Dec 30, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@benbc
Copy link

benbc commented Dec 30, 2024

Describe the bug
There appears to be a trivial typo in the code that rewrites routes into paths for HTML elements with "targets". The mapping of _verbs maps to put to hx-post instead of hx-put.

Minimal Reproducible Example

app = FastHTML()

@app.route("/target", methods=['get', 'put'])
def target(): pass

@app.get('/page')
def page(): return Button(get=uri('target')), Button(put=uri('target'))

resp = Client(app).get('/page')
assert 'hx-get="/target"' in resp.text
assert 'hx-put="/target"' in resp.text

The second assert fails because the generated HTML body is:

<body>
  <button hx-get="/target"></button>
  <button hx-post="/target"></button>
</body>

(Note hx-post instead of hx-put in the second button.)

Expected behavior
I'd expect put=uri('target') as a "target" to result in hx-put="/target" in the resulting HTML.

Environment Information

  • fasthtml version: 0.10.3
  • fastcore version: 1.7.28

Confirmation

  • I have read the FAQ (https://docs.fastht.ml/explains/faq.html)
  • I have provided a minimal reproducible example
  • I have included the versions of fastlite, fastcore, and fasthtml
  • I understand that this is a volunteer open source project with no commercial support.
@benbc benbc added the bug Something isn't working label Dec 30, 2024
@pydanny pydanny self-assigned this Jan 7, 2025
audreyfeldroy added a commit that referenced this issue Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants