Open librasteve opened 1 month ago
^^ I put the whole file here since I think it has a lot for this project:
hx-get
...<tr id="replaceMe">
<td colspan="3">
<button class='btn primary' hx-get="/contacts/?page=2"
hx-target="#replaceMe"
hx-swap="outerHTML">
Load More Agents... <img class="htmx-indicator" src="/img/bars.svg">
</button>
</td>
</tr>
I think this needs an idea for how to represent the hx-get / hx-post sequences in our htmx source ... my initial shot would be to have something like:
class hx-get {
has $.route; # <=== use this to set up the routes.raku
method next { sends the next htmx content }
}
This would allow arbitrary programmatic patterns for the back end to service hx-get, hx-post and so on
any f/back welcome
Here's the joe blow example done in flash / blueprint:
viz. https://github.com/Konfuzian/htmx-examples-with-flask/blob/main/examples/blueprints/click_to_edit.py
from flask import Blueprint, render_template, request
bp = Blueprint("click_to_edit", __name__, url_prefix="/click_to_edit")
data = [
{
"firstName": "Joe",
"lastName": "Blow",
"email": "joe@blow.com",
}
]
@bp.route("/", defaults={"id": 0})
@bp.route("/contact/<int:id>", methods=["GET", "PUT"])
def contact(id):
if request.method == "PUT":
data[id] = {k: request.form[k] for k in ("firstName", "lastName", "email")}
return render_template("click_to_edit/index.html.j2", contact=data[id])
@bp.route("/contact/<int:id>/edit")
def contact_edit(id):
return render_template("click_to_edit/edit.html.j2", contact=data[id])
OK - based on some work on implemented HTMX examples, I think that the initial emphasis on functional HTML can and should be moved out to a new raku module ... that said, there is an existing raku module HTML::Lazy
that already implements this functionality, so current plan is to freeze devt on the functional aspects here (in the branch freezefunc
) and to attempt to improve HTML::Lazy to do that part
my current plan is to leave the main branch as a vanilla crotmp oriented set of all the HTMX examples
where we have more exotic code styles like OO or Fn, then these can be placed on long-lived branches of their own
I have been looking at the cro documentation website and I really like the way that Cro uses markdown for those static pages...
The magic is done with the routes.pm6 file https://github.com/Raku/cro-website/blob/main/lib/Routes.pm6