velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Theo Keyzer <t...@ecnet.co.za>
Subject RE: Foreach macro
Date Tue, 24 Oct 2000 13:37:13 GMT

> #macro( loop $list )
> 	#if ($list.hasNext() )
> 		<table>
> 		#foreach
> 		</table>
> 	#end
> #end

> Now, this isn't a 'public' interface in the sense that it was meant for
> the designer, but you certainly bring up a good idea.  Maybe we add
> something to ArrayIterator like public boolean hasElements() to do
> this?  Or elementCount()? And document it.

> [What do we do if $list is a null reference?]

> geir

What I meant was to do the following:

#macro (loop $list)
  <table>
  #foreach ...
  </table>
#end

So if the $list is null or there are no data elements
then the macro does not run at all.

Theo Keyzer


Mime
View raw message