I'd like to tentatively announce the first alpha version of Hiccup 2.0.0. This release introduces automatically escaping of strings, which has been a frequently requested feature. Hiccup 1.0 had no way of distinguishing between a string of text and a fragment of HTML, so for version 2.0 a new type has been introduced to represent the latter.
A lot of projects depend upon Hiccup, and after thinking about it for a while, and watching Rich's Spec-ulation <https://www.youtube.com/watch?v=oyLBGkS5ICk> talk, I decided to introduce a new namespace rather than break backward compatibility. So although Hiccup 2.0.0 is a major version change, it should be backward compatible with version 1.0. The new namespace is hiccup2.core, and it works like this: (require '[hiccup2.core :refer [html raw]]) (str (html [:span "one < two"])) ;=> "<span>one < two</span>" Notice that now strings are escaped by default, but we also need to explicitly convert the HTML fragment into a string by using clojure.core/str . By using a compiled intermediate format, we gain a lot more potential flexibility. For example, possible future feature currently under consideration is to support different ways of formatting the HTML. Using an intermediate format allows us to do this after pre-compilation has taken place. Because this is an alpha release, the hiccup2.core namespace is not set in stone, but it does seem to be the simplest solution to the problem of incompatibility. Suggestions for better ways to solve this are welcome and encouraged. As well as escaping strings, additional syntax sugar for attributes has been introduced. This should be familiar to anyone using Reagent: (str (html [:span {:class ["foo" "bar"]} "example"])) ;=> "<span class=\"foo bar\">example</span>" (str (html [:span {:style {:color "red"}} "example"])) ;=> "<span style=\"color:red;\">example</span>" Please give the alpha release a spin, and if there are any incompatibilities please let me know. - James -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.