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

Symbols for attribute values? #156

Open rnikander opened 5 years ago

rnikander commented 5 years ago

Would you be interested in a pull request that got this to work:

[:form {:method 'post} ...

Like the following already works:

[:div {:style {:box-sizing 'border-box ...
rnikander commented 5 years ago

I just noticed that [:input {:type 'password ... also seems to work. So it appears be inconsistent. ?

weavejester commented 5 years ago
user=> (use 'hiccup2.core)
nil
user=> (str (html [:form {:method 'post}]))
"<form method=\"post\"></form>"

Can you provide an example where quoted symbols don't work?

rnikander commented 5 years ago

It appears to be triggered by having a variable within the HTML data:

user=> (let [x "foo"] (hic/html [:form {:method 'post} x]))
"<form method=\"quote post\">foo</form>"
weavejester commented 5 years ago

Thanks, I can reproduce that on master. That is a bug, and I would be interested in a PR to fix it.

rnikander commented 5 years ago

Okay, I don't have a PR at the moment. Looking at the code I can see sort of where the problem is (compile-attr-map, unevaluated?) but I don't understand it enough to fix it.