squint-cljs / squint

Light-weight ClojureScript dialect
https://squint-cljs.github.io/squint
669 stars 44 forks source link

Make child html reader tag optional? #479

Open borkdude opened 8 months ago

borkdude commented 8 months ago

In many cases it would be nice to not have to write the child html reader tag:

      #html ^lit/html
                   [:div {:class "bg-red-200"} (when true [:em "hello"]))]

However, there might be cases where a child vector is intended as a JS runtime array and not HTML:

      #html ^lit/html
                   [:div {:class "bg-red-200"} (pr-str [:em "hello"])]

This may be a reason to always make child tags explicit, however the 99% use case is probably the opposite. Maybe an explicit way to opt out of propagating could also work.

zampino commented 8 months ago

Or as a third case, have a different reader tag #html* that propagates (with the same ^tag) to child forms?

zampino commented 8 months ago

as for

      #html ^lit/html
                   [:div {:class "bg-red-200"} (pr-str [:em "hello"])]

we could always use vec to build an actual js array

zampino commented 8 months ago

+1 for the opposite :-)

however the 99% use case is probably the opposite