This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-14
Channels
- # announcements (31)
- # babashka (9)
- # beginners (4)
- # calva (67)
- # cider (6)
- # clj-yaml (10)
- # clojure (105)
- # clojure-austin (8)
- # clojure-bay-area (1)
- # clojure-europe (12)
- # clojure-germany (3)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-uk (2)
- # clojurescript (5)
- # core-logic (4)
- # data-science (29)
- # datomic (6)
- # dev-tooling (5)
- # emacs (3)
- # hyperfiddle (22)
- # introduce-yourself (4)
- # lsp (8)
- # malli (10)
- # off-topic (8)
- # pathom (74)
- # polylith (39)
- # practicalli (1)
- # reitit (3)
- # shadow-cljs (2)
- # spacemacs (3)
- # squint (4)
- # tools-deps (4)
@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>")
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 🙂