-
-
Save chirino/372407 to your computer and use it in GitHub Desktop.
This file contains 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
object transformer extends Transformer { | |
$(".people") { node => | |
// extract a template fragment from the html.. removes it | |
val odd = node.$template("tr.odd") | |
val even = node.$template("tr.even") | |
var c=0 | |
people.flatMap { p => | |
c += 1 | |
node << transform(if (c%2 == 0) even else odd) { t => | |
$(".name").contents = p.name | |
$(".location").contents = p.location | |
$"(.person").attribute("class") = "person " + (if (c % 2 == 0) "even" else "odd")) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment