Created
April 9, 2010 07:10
-
-
Save mva/360957 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/hiccup/core.clj b/src/hiccup/core.clj | |
index e803a16..b592620 100644 | |
--- a/src/hiccup/core.clj | |
+++ b/src/hiccup/core.clj | |
@@ -101,11 +101,17 @@ | |
"Render a HTML tag represented as a vector." | |
[element] | |
(let [[tag attrs content] (parse-element element)] | |
- (if (or content (container-tags tag)) | |
- (str "<" tag (render-attrs attrs) ">" | |
- (render-html content) | |
- "</" tag ">") | |
- (str "<" tag (render-attrs attrs) (tag-end))))) | |
+ (cond | |
+ (= tag "markup") | |
+ (apply str content) | |
+ | |
+ (or content (container-tags tag)) | |
+ (str "<" tag (render-attrs attrs) ">" | |
+ (render-html content) | |
+ "</" tag ">") | |
+ | |
+ :else | |
+ (str "<" tag (render-attrs attrs) (tag-end))))) | |
(defn- render-html | |
"Render a Clojure data structure to a string of HTML." | |
@@ -113,7 +119,7 @@ | |
(cond | |
(vector? data) (render-tag data) | |
(seq? data) (apply str (map render-html data)) | |
- :else (as-str data))) | |
+ :else (escape-html data))) | |
(defn- not-hint? | |
"True if x is not hinted to be the supplied type." | |
diff --git a/test/hiccup/core_test.clj b/test/hiccup/core_test.clj | |
index 0a92630..38fb558 100644 | |
--- a/test/hiccup/core_test.clj | |
+++ b/test/hiccup/core_test.clj | |
@@ -58,6 +58,14 @@ | |
(is (= (html [:div {:id "\""}]) | |
"<div id=\""\"></div>"))) | |
+(deftest escaped-character-data | |
+ (is (= (html [:div "<&"]) | |
+ "<div><&</div>"))) | |
+ | |
+(deftest markup-content | |
+ (is (= (html [:markup "<&"]) | |
+ "<&"))) | |
+ | |
(deftest attr-keys-can-be-strs | |
(is (= (html [:img {"id" "foo"}]) "<img id=\"foo\" />"))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment