- This gives you some really cool things but also introduces a limitation or two.
&
method ONLY exists on aCssSel
- With
CssSel
, you are guarranteed that it will go thru its arguments only once. Not so with plain(NodeSeq) => NodeSeq
What does this mean in practice? If you have a method:
renderBody = {
"image [src]" #> someBodyStuff andThen
"input code *" #> someBodyStuff &
}
The use of the andThen
inside it reduces this method to a (NodeSeq) => NodeSeq
. You are no longer able to evaluate its arguments only once, and because of this, you can't combine it with a CssSel
using &
.
Typically, if you have a large chain of CssSel
:
"header" #> someHeader &
"image [src]" #> someBodyStuff &
"input code *" #> someBodyStuff andThen
"pre code *" #> someBodyStuff &
"footer [style+]" #> someFooterStyle
you might refactor this into something more readable:
renderHeader &
renderBody &
renderFooter
However, because you've used andThen
inside the body transforms, then you can no longer chain renderHeader
together with renderBody
using &
. You must use andThen
instead.