weavejester / hiccup

Fast library for rendering HTML in Clojure
http://weavejester.github.io/hiccup
Eclipse Public License 1.0
2.68k stars 174 forks source link

html5 macro does not expand options #106

Open stain opened 9 years ago

stain commented 9 years ago
user=> (hiccup.page/html5 {:xml? true} [:head [:title "Hello"]] [:body "Hello"])
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>Hello</title></head><body>Hello</body></html>"

works.. but any way to set the options programmatically fails, and the options are inserted verbatim into the result:

user=> (let [options {:xml true}] 
  #_=>   (hiccup.page/html5 options [:head [:title "Hello"]] [:body "Hello"]))
"<!DOCTYPE html>\n<html>{:xml true}<head><title>Hello</title></head><body>Hello</body></html>"

This is probably because html5 does not evaluate the options symbol, and so (map? options) fails.

stain commented 9 years ago

Seems to also apply to the options of xhtml. Ideally the "options" should also be evaluated only once, so perhaps create options# abit earlier? I tried to fix it, but macro escape-unquote magic is not my favourite.. I made at least a unit test in https://github.com/stain/hiccup/tree/issue-106