htmx/www/content/extensions/path-params.md
Jyri-Matti Lähteenmäki 7866258936
add extension to populate path variables with request parameters (#1307)
* add extension to populate path variables with request parameters

* update extension readme
2023-12-13 18:31:28 -07:00

458 B

+++ title = path-params +++

This extension uses request parameters to populate path variables. Used parameters are removed so they won't be sent in the query string or body anymore.

Install

<script src="https://unpkg.com/htmx.org/dist/ext/path-params.js">

Usage

This would invoke URL /items/42?foo=bar

<div hx-ext="path-params">
    <a hx-get="/items/{itemId}" hx-vals='{"itemId": "42", "foo": "bar"}'>test</div>
</div>