Fork me on GitHub
#squint
<
2023-08-14
>
sergey.shvets00:08:40

@borkdude Here is the gist that implements hiccup compiler to jst templates. I dropped cljs.analyzer and mostly followed hicada implementation. There is one big difference into how it treats properties (string instead of keywords). Also, I made form expansion recursive, so nested let/ifs/etc. work. Not sure why hicada skipped that. There are a few "rcf" tests within, make sure to have it as dependency if you want to run code. (starting a new thread as we discussed as the old one is pretty long now) https://gist.github.com/shvets-sergey/ca91e05537592b0a92df58b46dffa3db Example:

(macroexpand '(jst cherry.core/js-template lit/html
                    [[:h2 "ToDo List"]
                     [:ul {:style {"margin" "10px"}
                           "class"  "todos"}
                      (todo-render (if hideCompleted
                                     (filter (fn [item]
                                               (false? (:completed item)))
                                             listItems)
                                     listItems))]
                     [:input {"id"         "newItem"
                              "aria-label" "New Item"}]
                     [:button {:on-click (.-add-todo this)} "Add ToDo"]
                     [:label
                      [:input {"type"       "checkbox"
                               :on-change (.-toggle-completed-todos this)}
                       "Hide Completed"]]]))
=>
(cherry.core/js-template
 lit/html
 "<h2>ToDo List</h2><ul style=\"margin:10px;\" class=\"todos\">"
 (todo-render (if hideCompleted (filter (fn [item] (false? (:completed item))) listItems) listItems))
 "</ul><input id=\"newItem\" aria-label=\"New Item\"></input><button @click="
 (.-add-todo this)
 ">Add ToDo</button><label><input type=\"checkbox\" @change="
 (.-toggle-completed-todos this)
 ">Hide Completed</input></label>")

👍 2
zane01:08:50

I wonder if it’s time for a channel for web component-related conversations?

zane01:08:55

This is very exciting!

sergey.shvets03:08:07

I want to build a macro around hiccup for lit components. I have something working but there are still too many use cases to support. Need to work on it (much) more 🙂