Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
luontola committed Nov 30, 2023
1 parent 48ba3f7 commit 34a1656
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/hiccup/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

(defmacro build-string [& strs]
(let [strs (concatenate-strings strs)
w (gensym)]
w (gensym)]
(case (count strs)
0 ""
1 (let [arg (first strs)]
Expand Down Expand Up @@ -333,24 +333,24 @@
(defmethod compile-element ::literal-tag
[[tag attrs & content]]
(let [[tag tag-attrs _] (normalize-element-form [tag])
attrs-sym (gensym "attrs")]
attrs-sym (gensym "attrs")]
`(let [~attrs-sym ~attrs]
(build-string
(if (map? ~attrs-sym)
~(if (container-tag? tag content)
`(build-string ~(str "<" tag)
(render-attr-map (merge ~tag-attrs ~attrs-sym))
">")
`(build-string ~(str "<" tag)
(render-attr-map (merge ~tag-attrs ~attrs-sym))
~(end-tag)))
(build-string ~(str "<" tag (render-attr-map tag-attrs) ">")
~@(compile-seq [attrs-sym])))
;; content and ending tag (when the above code did not emit an ending tag)
(when (or ~(boolean (container-tag? tag content))
(not (map? ~attrs-sym)))
(build-string ~@(compile-seq content)
~(str "</" tag ">")))))))
(if (map? ~attrs-sym)
~(if (container-tag? tag content)
`(build-string ~(str "<" tag)
(render-attr-map (merge ~tag-attrs ~attrs-sym))
">")
`(build-string ~(str "<" tag)
(render-attr-map (merge ~tag-attrs ~attrs-sym))
~(end-tag)))
(build-string ~(str "<" tag (render-attr-map tag-attrs) ">")
~@(compile-seq [attrs-sym])))
;; content and ending tag (when the above code did not emit an ending tag)
(when (or ~(boolean (container-tag? tag content))
(not (map? ~attrs-sym)))
(build-string ~@(compile-seq content)
~(str "</" tag ">")))))))

(defmethod compile-element :default
[element]
Expand Down

0 comments on commit 34a1656

Please sign in to comment.