fasthtml
fasthtml copied to clipboard
[BUG] Auto-rewriting of routes to paths changes hx-put to hx-post
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
- [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.