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

Multiple files input cannot be represented in hiccup #148

Closed orolle closed 6 years ago

orolle commented 6 years ago

<input type="file" name="img" multiple></input>

I could not represented the above html in hiccup because "multiple" is not a regular attribute. I also tried http://html2hiccup.buttercloud.com/ to convert it into hiccup but it also failed.

[:input {:multiple :type "file"} ] Error: Map literals must contain an even number of forms. [:input {:multiple nil :type "file"} ] False: Translates to <input type="file"></input>

weavejester commented 6 years ago
(html {:mode :html5} [:input {:multiple true :type "file"}])

Or use hiccup.page/html5. So long as the mode is set to HTML5 at the top level, it will use attributes without values. For compatibility reasons, the default is to mirror the name and value, which is treated by browsers as the same thing.

orolle commented 6 years ago

Thanks a lot! That worked! :+1: