You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Diane Holt <ho...@yahoo.com> on 2002/03/06 01:24:13 UTC

Getting lines of text individually

Is there any way to say:
Here are several
lines of text
treat them as
individual items
in a #foreach.

Thanks,
Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Getting lines of text individually

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/5/02 7:24 PM, "Diane Holt" <ho...@yahoo.com> wrote:

> Is there any way to say:
> Here are several
> lines of text
> treat them as
> individual items
> in a #foreach.

Sure

#set($lines= ["Hello","there","Diane"])

#foreach($line in $lines)
$line
#end

Will output

Hello
there
Diane

Now, it's no fun to specify lines of text like this in the Object array
(that's what we call the square bracket thingy...), but you could just as
well put that in anything iterable (List, for example) in your Java code,
and iterate over that as shown..

Geir


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>