Quick question. Can I embed scittle inside hiccup but as code? Like not as string? Say something like:
[:fieldset
{:onchange '(-> (JS/querySelector "input[type=\"checkbox\"]") (.setCustomValidity ""))}
[:legend "Frequency"]
[:label
[:input {:type "checkbox" :name "daily"}]
"Daily"]
[:label
[:input {:type "checkbox" :name "weekly"}]
"Weekly"]
[:label
[:input {:type "checkbox" :name "monthly"}]
"Monthly"]]Some interesting hiccup js transpilation tricks https://scicloj.github.io/tableplot/tableplot_book.transpile_reference.html
Also, maybe Datastar could be useful if Htmx gets messy with client side stuff requiring extra libraries etc.
Very interesting, thanks!
I was in the same situation where I wanted some scripting next to HTMX and I managed to be able to with some clojure code for scripting but in the end it was easier to just go with https://hyperscript.org/. Works pretty well for some small scripts.
I tried hyperscript but didn't love learning a new language.
I also really much lick the combo hiccup + htmx + hyperscript. However, I thought that trying to replace hyperscript with some clojure dialect would have been a good idea, or, at least, a good attempt and so I tried to integrate scittle in this way (see pic) In order to make this working: • a small dom manipulation library embedded in scittle (xdom) • some macros in the server to compile attributes for scittle • a custom eval-string • an observer (for signals, although it's just an experiment) The goal would be to enhance hiccup with client side scripting
who converts the hiccup to html, is this server or client side?
Server side
Hum, currently it's the hiccup library from weave jester. But like, is there an alternate hiccup lib that would know to convert the scittle. Or just a lib that I can wrap the scittle code and it'll return it as a string And maybe also, a string that scittle will pickup inside the html?
anything rendered in the browser has to be a string with some javascript in there so what you need there is either a compiler (#squint might be a good fit, let me link an example shortly) or a call to the interpreter explicitly, e.g. scittle.core.eval_string(...)
here are some squint examples using babashka (but this is irrelevant, it can be whatever server side clojure hiccup stuff): https://github.com/squint-cljs/squint/tree/main/examples/babashka
note for example this: https://github.com/squint-cljs/squint/blob/e4781305a2834d5eb68ac60324da80489e3a287a/examples/babashka/index.clj#L35
Cool, ya squint might work even better in this case. I'll explore both.
I've found with HTMX you hit some limitations sometimes, and a little bit of embedded JS is needed. Not enough to go and make a separate script file and all that though. But then it's annoying inside hiccup to write some JS inside a string. But writing clojure code, that could be interpreted as scittle or compiled as squint would be much nicer.