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

HTMX addition #10

Closed
algunion opened this issue Jun 19, 2023 · 6 comments
Closed

HTMX addition #10

algunion opened this issue Jun 19, 2023 · 6 comments

Comments

@algunion
Copy link

algunion commented Jun 19, 2023

I want to integrate HTMX closely with Cobweb.jl.

I will do this anyway for my own needs - in one way or another - but I think it can be nice to have this in a public repo so other Julia users can benefit from it.

HTMX can already be used with Cobweb.jl (it is just a matter of adding attributes). However, I would like to add some dedicated types and functions to make the process smoother.

Would you consider a PR (given I don't touch the already implemented functionality)?

Or should I do it as a standalone extension wrapping the Cobweb.jl?

More about HTMX here: https://htmx.org/docs/

@joshday
Copy link
Member

joshday commented Jun 19, 2023

I'm a fan of HTMX and I toyed with an idea here: https://github.com/joshday/HTMX.jl (but I still think it's too verbose).

If it's simple/small enough, I don't mind having the code live here.

@algunion
Copy link
Author

OK. Since I want to implement it for myself anyway - I'd like to try it, and you can decide later if it is worth accommodating here.

@VarLad
Copy link

VarLad commented Sep 22, 2024

@joshday Do you know of a better interface, or have any specific ideas as to what the HTMX integration should look like?

@joshday
Copy link
Member

joshday commented Sep 23, 2024

Out of the box, there isn't much that needs to be done in terms of integration:

<button hx-post="/clicked" hx-swap="outerHTML">
  Click Me
</button>

Is this:

using Cobweb: h

h.button(var"hx-post"="/clicked", var"hx-swap"="outerHTML",
    "Click Me"
)

I'm actually surprised I haven't already done automatic translation of underscores to dashes. I'll make that change so then it's just this:

using Cobweb: h

h.button(hx_post="/clicked", hx_swap="outerHTML",
    "Click Me"
)

@VarLad
Copy link

VarLad commented Sep 23, 2024

This looks great! 😀
Thanks a lot. Over time I'll try making a small demo with this and Oxygen.jl

@VarLad
Copy link

VarLad commented Sep 23, 2024

@joshday Does documenting this as a usage example somewhere, along with installing htmx sound good?
For installation, I believe this should be good enough?

head = h.head(
    h.script(
        src="https://unpkg.com/htmx.org@2.0.2",
        integrity="sha384-Y7hw+L/jvKeWIRRkqWYfPcvVxHzVzn5REgzbawhxAuQGwX1XWe70vji+VSeHOThJ",
        crossorigin="anonymous"
    )
)

(taken from https://htmx.org/docs/#installing )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants