Skip to content

Instantly share code, notes, and snippets.

@JacobNinja
Last active September 17, 2015 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JacobNinja/796b745c27c898633d60 to your computer and use it in GitHub Desktop.
Save JacobNinja/796b745c27c898633d60 to your computer and use it in GitHub Desktop.
Hiccup templates using syntax-quote
(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