Range selectors

67 views
Skip to first unread message

Stuart Campbell

unread,
May 4, 2012, 3:16:09 AM5/4/12
to enliv...@googlegroups.com
I'm trying to define a snippet that transforms a range of nodes using the {from to} selector.

The following successfully selects nodes from p:first-child to p:last-child:

  (select
    (html-resource "foo.html")
    {[[:p first-child]] [[:p last-child]]})

However, I'd like to make this more specific and select that range within the context of another node.

I tried this, but it returns an empty list:

  (select
    (html-resource "foo.html")
    [:body :> {[[:p first-child]] [[:p last-child]]}])

Does this make sense? Am I trying to do an impossible thing?

Thanks,
Stuart

Christophe Grand

unread,
May 4, 2012, 3:19:56 AM5/4/12
to enliv...@googlegroups.com
Hi,

It doesn't compose in this way, try:

(select
    (html-resource "foo.html")
    {[:body :> [:p first-child]] [:body :> [:p last-child]]})

this should work.

Christophe


--
You received this message because you are subscribed to the Google Groups "Enlive" group.
To post to this group, send email to enliv...@googlegroups.com.
To unsubscribe from this group, send email to enlive-clj+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/enlive-clj?hl=en.



--
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

Stuart Campbell

unread,
May 4, 2012, 3:37:15 AM5/4/12
to enliv...@googlegroups.com
Great, thanks Christophe. That works.
Reply all
Reply to author
Forward
0 new messages