Skip to content

Commit

Permalink
changes for cherry
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Sep 12, 2024
1 parent 0658b0b commit 8df5c90
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
5 changes: 0 additions & 5 deletions src/squint/compiler.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,6 @@
(let [env (assoc env :jsx true)]
(emit form env)))

(defmethod emit-special 'squint-compiler-html [_ env [_ form]]
(let [env (assoc env :html true :jsx true)
form (vary-meta form assoc :outer-html true)]
(emit form env)))

(def squint-parse-opts
(e/normalize-opts
{:all true
Expand Down
32 changes: 21 additions & 11 deletions src/squint/compiler_common.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1042,14 +1042,15 @@ break;}" body)

(defn emit-css
[v env]
(-> (reduce
(fn [acc [k v]]
(str acc
(emit k env) ":"
(emit v env) ";"))
""
v)
(wrap-double-quotes)))
(let [env (assoc env :html-attr true)]
(-> (reduce
(fn [acc [k v]]
(str acc
(emit k env) ":"
(emit v env) ";"))
""
v)
(wrap-double-quotes))))

(defn jsx-attrs [v env]
(let [env (expr-env env)
Expand All @@ -1066,9 +1067,13 @@ break;}" body)
(let [rest-opts (dissoc v* :&)]
(when-let [dyn (:has-dynamic-expr env)]
(reset! dyn true))
(format "${squint_html.attrs(%s,%s)}"
(emit (get v* :&) (dissoc env :jsx))
(emit rest-opts (dissoc env :jsx))))
(let [env (assoc env :js true)
cherry? (= :cherry *target*)]
(format "${squint_html.attrs(%s,%s)}"
(emit (cond->> (get v* :&)
cherry? (list `clj->js)) (dissoc env :jsx))
(emit (cond->> rest-opts
cherry? (list `clj->js)) (dissoc env :jsx)))))
(str/join " "
(map
(fn [[k v]]
Expand Down Expand Up @@ -1204,3 +1209,8 @@ break;}" body)
(format "[%s]"
(str/join ", " (emit-args env expr))))
env)))

(defmethod emit-special 'squint-compiler-html [_ env [_ form]]
(let [env (assoc env :html true :jsx true)
form (vary-meta form assoc :outer-html true)]
(emit form env)))

0 comments on commit 8df5c90

Please sign in to comment.