-
-
Save jstrachan/372423 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val xml = | |
<table class="people"> | |
<thead> | |
<tr> | |
<th>Name</th> | |
<th>Location</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td class="name">James</td> | |
<td class="location">Beckington</td> | |
</tr> | |
</tbody> | |
</table> | |
object transformer extends Transformer { | |
$(".people tbody").contents { node => | |
val odd = node.$("tr.odd") | |
val even = node.$("tr.even") | |
var c=0 | |
people.flatMap { p => | |
c += 1 | |
transform(if (c%2 == 0) even else odd) { t => | |
$(".name").contents = p.name | |
$(".location").contents = p.location | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment