Skip to content

Instantly share code, notes, and snippets.

@gtrak
Created February 28, 2012 02:41
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 gtrak/1928815 to your computer and use it in GitHub Desktop.
Save gtrak/1928815 to your computer and use it in GitHub Desktop.
static hiccup generation
(defmacro defpartial
"Create a function that returns html using hiccup. The function is
callable with the given name."
[fname params & body]
`(defn ~fname ~params
(h.core/html
~@body)))
(defmacro fn-partial
"Create a function that returns html using hiccup."
[params & body]
`(fn ~params
(h.core/html
~@body)))
(defmacro defpartial-static
"Pre-render on compilation, no params"
[name & body]
(let [b `(fn-partial [] ~@body)
value ((eval b))]
`(defpartial ~name []
~value)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment