Skip to content

Commit

Permalink
Add ability to change self-closing behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvik committed Mar 20, 2010
1 parent e368418 commit 43fc6b2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/hiccup/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
clojure.contrib.java-utils)
(:import java.util.Map))

(def #^{:doc "Determines the method to self-close elements."}
*html-mode* :xhtml-strict)

(def #^{:doc "The various self-close forms"
:private true}
self-close {:html4 " >"
:xhtml-strict " />"
:xhtml-transitional " />"})

(defn escape-html
"Change special characters into HTML character entities."
[text]
Expand Down Expand Up @@ -76,7 +85,7 @@
(str "<" tag (make-attrs attrs) ">"
(render-html content)
"</" tag ">")
(str "<" tag (make-attrs attrs) " />"))))
(str "<" tag (make-attrs attrs) (self-close *html-mode*)))))

(defn render-html
"Render a Clojure data structure to a string of HTML."
Expand Down

0 comments on commit 43fc6b2

Please sign in to comment.