Last active
September 17, 2015 16:59
-
-
Save JacobNinja/796b745c27c898633d60 to your computer and use it in GitHub Desktop.
Hiccup templates using syntax-quote
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
(defn- make-stylesheet [link] | |
[:link {:rel "stylesheet" :href link}]) | |
;; Programatic style | |
[:body (into [:head] (map make-stylesheet ["foo.css" "bar.css"])) | |
[:p "content"]] | |
;; Syntax-quote style | |
`[:body [:head ~@(map make-stylesheet ["foo.css" "bar.css"])] | |
[:p "content"]] | |
;; Same output for both styles | |
[:body | |
[:head | |
[:link {:rel "stylesheet", :href "foo.css"}] | |
[:link {:rel "stylesheet", :href "bar.css"}]] | |
[:p "content"]] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment