In the middle of building some HTML like this:
<div>
<h2>Hello World</h2>
{
...create a list of elements, e.g.
<li>something</li>
<li>something else</li>
}
where, in reality, inside the {} blocks is an iterator and a while
loop that calls a routine that returns a NodeSeq, but being inside the
{} block, that NodeSeq is not added as it is in the above sketch. So,
the code is changed to:
var x: Nodeseq =
<div>
<h2>Hello World</h2>
{
do some calculations that set this:
> var x: Nodeseq =
> <div>
> <h2>Hello World</h2>
> {
> do some calculations that set this:
var y:NodeSeq = doSomething()
here's where I'd love to do something trivial like:
x.++(y)
but the compiler simply hates that. Didn't like :+ either; -that takes a Node
The question is this: short of a messy foreach loop, is there some
simple way to append y to x?
Many thanks
Jack
Actually, the second instance is close to what I am doing, except that
it's a bit more complex:
<li id={"node_"+loxa}>
<a class="nodehref" href={lox}><img class="nodeimg"
src={"/images"+node.getSmallIcon()}/><span
class="nodetitle">{node.getLabel("en")}</span></a>
{
if (snappers != null) {
itr = snappers.iterator
<ul><div style='height: 100%; overflow: visible;'>
while(itr.hasNext)
createTree(start,count,itr.next(),credentials)
</div></ul>
}
}
</li>
There is an if block and while loop embedded. What that returns is a
nested while(itr.hasNext)
createTree(start,count,itr.next(),credentials)
inside the nested <ui> </ui> block.
That's the reason for my query: the idea is to isolate the while loop
inside {} and use something like ++ except that I want them nested,
not appended where you see the "," as per your example.
The game is to isolate the while loop and still get the NodeSeq output
of createTree()
Thanks
Jack
> --
> Lift, the simply functional web framework: http://liftweb.net
> Code: http://github.com/lift
> Discussion: http://groups.google.com/group/liftweb
> Stuck? Help us help you:
> https://www.assembla.com/wiki/show/liftweb/Posting_example_code
The option is thus to return to the original code, which built the
structure with a StringBuilder, and then uses XML.loadString. I was
trying to work around that and use the elegant XML tools available; It
appears that, in this case, I cannot do that.
Thanks
Jack
you may want to ask on the scala mailing list or stackoverflow site under the Scala tag, as it is not limited to lift.
Regards
Diego
Sent from my android cell
Many thanks.
Jack