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. 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?




                                                                                       
                    
                    "Geir Magnusson                                                    
                    
                    Jr."                    To:     [EMAIL PROTECTED]    
                    
                    <geirm@optonline        cc:                                        
                    
                    .net>                   Subject:     Re: Question/Idea             
                    
                    Sent by:                                                           
                    
                    [EMAIL PROTECTED]                                                   
                    
                    lny.cv.net                                                         
                    
                                                                                       
                    
                                                                                       
                    
                    03/30/2001 11:18                                                   
                    
                    AM                                                                 
                    
                    Please respond                                                     
                    
                    to velocity-dev                                                    
                    
                                                                                       
                    
                                                                                       
                    




[EMAIL PROTECTED] wrote:
>
> I understand that their maybe  other ways to address this issue, but what
> do people think about adding something like the following to Velocity?

What issue?

>
> #macro(macroWithArgs, $arg1, $arg2)
>      ...
> #end
>
> #macroWithArgs($arg1):
>   #arg2
>      VM VTL code
>   #end
> #end

What are you trying to say here?  Macro's already can have args....  see
the Users guide...

> I think that this allows for greater flexibility in the template lib.
model
> and in the construction of presentation widgets. The idea is to be able
to
> be able to do things like pass row definitions to table widgets more
easily
> (and in-line). I am new to this list so I don't know if this has been
> talked about or if there is a better way to do this? What are peoples
> thoughts?

Again, don't quite understand what problem you are addressing.

geir

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




Reply via email to