Tom Hickey <thic...@gmail.com> writes:

> Regarding your first question, you can use (net.cgrand.enlive-html/
> escaped your-string) to skip the escaping of your strings.

Thanks, that's helpful.

I've also noticed one more oddity. Consider this snippet:

(deftemplate index "foo/bar/template.html" [articles]
  [:div.articles] (for [{:keys [title content]} articles]
                    ~(at
                      [:h2] title
                      [:p.content] (escaped content))))

Applied to this template:

<div class="articles">
  <h2></h2>
  <p class="content"></p>
</div>

When the thing to insert into the element is just a string (as is the
case with the h2 element), it gets inserted inside the element.  But in
the second case, the content paragraph is _replaced_ with the escaped
content rather than putting the escaped content inside the paragraph
tag. So if title had the value "Congratulations" and content had the
value "You win", the final result would be something like:

  <h2>Congratulations</h2>
  You win

The paragraph node disappears...

>From what I can tell the difference seems to be that it goes inside the
node if it's a string, and it replaces the node if it's a function call,
even if the function call results in a string.

This behaviour seems really strange. I feel like maybe there's some
logic I'm missing and that it's not the string/function call difference
that determines replacement vs insertion, but I can't figure out why
it's behaving this way. Would appreciate any explanation.

thanks,
Phil

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to