On Jul 11, 6:01 pm, Robert Campbell <rrc...@gmail.com> wrote:
> Hey guys,
>
> I'm just curious why Christophe chose to return seq instead of a str
> for Enlive for his template functions.
>
> Example:
>
> (deftemplate my-page-transformation "index.html" [message style]
> [:style] (content style)
> [:h1] (content message))
>
> orchid> (my-page-transformation "my wonderful header" "h1 { color: blue }")
> ("<html>" "\n\t" "<head>" "\n\t\t" "<style>" "h1 { color: blue }"
> "</style>" "\n\t" "</head>" "\n\t" "<body>" "\n\t\t" "<h1>" "test"
> "</h1>" "\n\t" "</body>" "\n" "</html>")
>
> It's trivial to call (apply str (my-page..)) but I'm just curious
> about the thinking behind using a seq. Is it related to xml-seq and
> traversing the tree?
>
Most likely Enlive generates each of those fragments separately;
Forcing them into a single string at the end would wasteful in case
the user intends to write the output into a stream (which can be done
a fragment at a time.) Thus, leaving the choice to the user seems like
a good decision.
Or maybe it's just a lazy seq, in which case using str on it would
force it to be strict. :)
> Thanks,
>
> Rob
--
Jarkko
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---