[EMAIL PROTECTED] wrote:
> 
> I am sorry I was not clear here. I will try to explain better. Also I am
> just starting to use Velocity and so my knowledge is still limited. 

No worries....

> All
> that I was looking to do was to be able to provide the definition for what
> an argument looks like at the time a macro is invoked.
> 
> #table($title, $data):
>   #columns
>      <TH>$row.one</TH> <TD>$row.two</TD>
>   #end
> #end
> 
> where table might be defined as
> 
> #vmmacro(table, $title, $data, $columns)
>     <TABLE>
>     #foreach ($row in $data)
>         <TR>
>      #parse($columns)
>         </TR>
>     #end
>    </TABLE>
> #end
> 
> Obviously in such a situation you wouldn't want to bind calling the table
> macro to know the name '$row'. In a situation like that though parse would
> need to take an optional arg as the new context, like
>      #parse ($columns, $row)
> 
> That is not really a great idea though as you have a macro method already.
> Thinking out loud, what I am talking about its just short hand for a scoped
> macro call and this could just as easily look like:
> 
> #table($title, $data)
>   #vmmacro(columns, $row)
>      <TH>$row.one</TH> <TD>$row.two</TD>
>   #end
> #end
> 
> and
> 
> #vmmacro(table, $title, $data, $columns)
>     <TABLE>
>     #foreach ($row in $data)
>         <TR>
>      #columns($row)
>         </TR>
>     #end
>    </TABLE>
> #end
> 
> This IMHO allows for larger, more complex presentation widgets to be
> defined and removes the need to define things like row definitions apart
> from the tables that might use them. Hopefully I explained a bit better
> this time?

I have to admit, I still don't get it, but I think there is a bit of
cloudiness in how you percieve that VMs work.  Briefly : 

All VMs are 'line directives', in that they don't have a body like #if()
does.

For table generation, you could define two VMs as :

#macro( table $title $data )
  Table of $title
  <table>
    #foreach( $row in $data )
      #makerow( $row )
    #end
  </table>
#end

#macro( makerow $rowdata )
   <tr>
    #foreach( $field in $rowdata)
     <td>$field</td>
    #end
   </tr>
#end


and then make a table as :

#table( "Foobar" $mydata )

which would call the VM table, which would call the VM  makerow.

Now, starting with this as a basis, what doesn't this solve for you, or
what should be changed?

geir

-- 
Geir Magnusson Jr.                               [EMAIL PROTECTED]
Developing for the web?  See http://jakarta.apache.org/velocity/

Reply via email to