Squery examples not working

28 views
Skip to first unread message

Wille Faler

unread,
Mar 12, 2011, 1:12:59 PM3/12/11
to sca...@googlegroups.com
Reporting a documentation "defect" here:

The more "complex" example of Squery seems to have a problem: 

Reproducing the code and XML input line-by-line throws a compilation problem:
type mismatch;
[error]  found   : org.fusesource.scalate.scuery.Transform
[error]  required: Traversable[?]
[error]       new Transform(node) {
[error]       ^


Full source of the test code: https://gist.github.com/867408

I suppose the actual code should be more akin to that in TransformContentsWithLoopTest.scala in the test source?

James Strachan

unread,
Mar 14, 2011, 8:22:53 AM3/14/11
to sca...@googlegroups.com, Wille Faler
On 12 March 2011 18:12, Wille Faler <wille...@gmail.com> wrote:
> Reporting a documentation "defect" here:

Thanks!

Hmm, I just copied your test case into a new test case in Scalate...

https://github.com/scalate/scalate/blob/master/scalate-core/src/test/scala/org/fusesource/scalate/scuery/WilleScueryTest.scala

I swizzled the code ever so slightly to test the results (notice we
use result.$(cssSelector) to filter the DOM with CSS3 selectors -
cool!).
https://github.com/scalate/scalate/blob/master/scalate-core/src/test/scala/org/fusesource/scalate/scuery/WilleScueryTest.scala#L26

Seems to work for me in sbt and mvn with scala 2.8.1.

The compile error message you got seems to be that the implicit
conversion on the Transform object to a NodeSeq isn't being
recognised. I wonder which Scala compiler version you were using?

One alternative is to call the method explicitly instead (see the .toNodes)...

people.flatMap{
p =>
new Transform(node) {
$(".name").contents = p.name
$(".location").contents = p.location
}.toNodes
}

Its looking like we've currently an implicit conversion from Transform
to NodeSeq on both the Transform object and on the class.

I wonder if this import fixes it?

import org.fusesource.scalate.scuery.Transform._

Though I thought the compiler was meant to import implicit conversions
on types you have in scope?

--
James
-------
FuseSource
Email: ja...@fusesource.com
Web: http://fusesource.com
Twitter: jstrachan
Blog: http://macstrac.blogspot.com/

Open Source Integration

Wille Faler

unread,
Mar 14, 2011, 8:56:57 AM3/14/11
to James Strachan, sca...@googlegroups.com
Hi,
I'm using 2.8.1 as my compiler with sbt.

Got the example working with a slightly different look to the code:

..just wanted to point out the potential confusion that could occur for those not willing to dive into the code.
Maybe the implicit should be explicitly imported in the example to make it work? (pun intended).

James Strachan

unread,
Mar 14, 2011, 9:02:03 AM3/14/11
to Wille Faler, sca...@googlegroups.com
I wonder if you're previous failing test worked if you added the
import I mentioned? Just trying to work out what import is required :)

Wille Faler

unread,
Mar 14, 2011, 9:07:31 AM3/14/11
to James Strachan, sca...@googlegroups.com
That'll probably do it.. :)

James Strachan

unread,
Mar 14, 2011, 9:16:27 AM3/14/11
to sca...@googlegroups.com, Wille Faler
On 14 March 2011 13:07, Wille Faler <wille...@gmail.com> wrote:
> That'll probably do it.. :)

Done! :)
https://github.com/scalate/scalate/commit/baa8eafe1651cb1fb9a2270a635b6d8544c70ff4

should go live next website redeploy...

Reply all
Reply to author
Forward
0 new messages