You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Igor Abade V. Leite" <ig...@cosespseguros.com.br> on 2002/07/16 15:13:29 UTC

Optional parameters in Velocimacro

Is there a way to define optional parameters in a Velocimacro?
For instance, given the following macro:

#macro ( myMacro $param1 $param2 $param3 )
    (some content)
#end

Can I do something like the snippet below?

#myMacro('Val1', , 'Val3')

Thanks,
	Igor



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


RES: Optional parameters in Velocimacro

Posted by "Igor Abade V. Leite" <ig...@cosespseguros.com.br>.
I'm trying to write a Grid-like Velocimacro, which displays a
properly-wrapped 
ResultSet in a table with a pager and all sorts of whistles and bells. 

I'd like to give to some of the parameters a default value, so the user
could 
save some typing - e.g. a #DataColumn macro would require a Width
parameter, 
which can be completely omitted by the user - in such case, the macro
would render
a <td> element with no "width" attribute. Same goes for other
attributes, like 
"nowrap" and "style".

In the worst circumstances, I'd have to write multiple versions of the
same macro,
resulting in something that barely resembles a method overloading. But,
since there
is no macro overloading, I'd have to use different names for each macro
version, and
that's exactly what I'm trying to avoid.

	Thanks,
		Igor

-----Mensagem original-----
De: Geir Magnusson Jr. [mailto:geirm@adeptra.com] 
Enviada em: terça-feira, 16 de julho de 2002 10:30
Para: velocity-user@jakarta.apache.org
Assunto: Re: Optional parameters in Velocimacro


On 7/16/02 9:13 AM, "Igor Abade V. Leite" <ig...@cosespseguros.com.br>
wrote:

> Is there a way to define optional parameters in a Velocimacro? For 
> instance, given the following macro:
> 
> #macro ( myMacro $param1 $param2 $param3 )
>   (some content)
> #end
> 
> Can I do something like the snippet below?
> 
> #myMacro('Val1', , 'Val3')
> 

No.  the parser will throw a fit.

What would you want $param2 to be in the macro in that case?

-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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



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


Re: Optional parameters in Velocimacro

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 7/16/02 9:13 AM, "Igor Abade V. Leite" <ig...@cosespseguros.com.br>
wrote:

> Is there a way to define optional parameters in a Velocimacro?
> For instance, given the following macro:
> 
> #macro ( myMacro $param1 $param2 $param3 )
>   (some content)
> #end
> 
> Can I do something like the snippet below?
> 
> #myMacro('Val1', , 'Val3')
> 

No.  the parser will throw a fit.

What would you want $param2 to be in the macro in that case?

-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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