I mention it because it is a very elegant solution to the problem of
constructing html in clojure. An equivalent of your code would be something
like:
(html
(html5
[:table {:border: 1 :cellpadding :10 :style {:font-family "Arial"
:font-size "16px" :margin "10px" :width "100%"}}
[:tr
[:th {:bgcolor "black" :color "white"} "Quote"]
[:th {:bgcolor "black" :color "white"} "Author"]]]))
The great thing is that it is just data structures so you can do things
like:
(def headers ["Quote" "Author"])
(html
(html5
[:table {:border: 1 :cellpadding :10 :style {:font-family "Arial"
:font-size "16px" :margin "10px" :width "100%"}}
[:tr
(for [header headers]
[:th {:bgcolor "black" :color "white"} "header"])]]))
HTH.
On Thursday, 26 February 2015 20:23:59 UTC, Cecil Westerhof wrote:
>
> 2015-02-26 20:46 GMT+01:00 Colin Yates <[email protected] <javascript:>>:
>
>> Hi Cecil - have you looked at hiccup?
>>
>
>
> ​Not yet.​
>
> On 26 February 2015 at 19:39, Cecil Westerhof <[email protected]
>> <javascript:>> wrote:
>> > At the moment I have the following code:
>> > (str "<html>"
>> > "<table border='1' cellpadding='10'"
>> > "style='font-family:Arial; font-size:16px; margin:
>> > 10px;width:100%'>"
>> > "<tr>"
>> > "<th bgcolor='black' color='white'>Quote</th>"
>> > "<th bgcolor='black' color='white'>Author</th>"
>> > "</tr>")
>> >
>> > But I want to make it more generic: the th lines should be data-driven.
>> > There is a headers variable and when this contains:
>> > '(:quote "Quote" :author "Author")
>> >
>> > Then the above should be generated. So for every odd position (counting
>> from
>> > 0) a th string should be inserted. How would I do this?
>>
> ​​
>
> --
> Cecil Westerhof
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.