logo       

Re: 2 macros with the same name allowed?: msg#00223

jakarta.velocity.user

Subject: Re: 2 macros with the same name allowed?

No - we don't have name overloading with VMs.

On Wednesday, November 27, 2002, at 07:32 PM, Rodney Schneider wrote:

Hi all,

I have a really long macro called displayAllMessages which is used to
display nicely formatted messages to the user of my web application.
The macro takes two arguments; the messages to display and the color to
display them...

#macro (displayAllMessages $data $color)
<snip>
#end

I want to make the default color red, so I have created another macro
that calls the long macro...

#macro (displayAllMessages $data)
#displayAllMessages($data, "red")
#end

However, when I call the macro from one of my templates like so...

#displayAllMessages($data, "black")

... I get the attached error messages from Velocity.

Am I allowed to have two macros with the same name call each other in
Velocity? BTW, I'm using Velocity 1.2.

Regards,

-- Rodney


----------------------------------------------------
Wed Nov 27 18:05:10 GMT+11:00 2002 [error] Parser Exception:
screens/Upload.vm : org.apache.velocity.runtime.parser.ParseException:
Encountered "," at line 84, column 34.
Was expecting one of:
"[" ...
<RPAREN> ...
<WHITESPACE> ...
<STRING_LITERAL> ...
"true" ...
"false" ...
<NUMBER_LITERAL> ...
<WORD> ...
<IDENTIFIER> ...
"{" ...
"}" ...
<DOT> ...

Wed Nov 27 18:05:10 GMT+11:00 2002 [error]
ResourceManager.getResource() parse exception:
org.apache.velocity.exception.ParseErrorException: Encountered "," at
line 84, column 34.
Was expecting one of:
"[" ...
<RPAREN> ...
<WHITESPACE> ...
<STRING_LITERAL> ...
"true" ...
"false" ...
<NUMBER_LITERAL> ...
<WORD> ...
<IDENTIFIER> ...
"{" ...
"}" ...
<DOT> ...

Wed Nov 27 18:05:10 GMT+11:00 2002 [error] VM #displayAllMessages:
error : too few arguments to macro. Wanted 2 got 1 -->

org.apache.velocity.runtime.resource.loader.FileResourceLoader
Wed Nov 27 18:05:10 GMT+11:00 2002 [error] VM error :
displayAllMessages. Null AST
----------------------------------------------------

--
To unsubscribe, e-mail: <mailto:velocity-user-unsubscribe@xxxxxxxxxxxxxxxxxx>
For additional commands, e-mail: <mailto:velocity-user-help@xxxxxxxxxxxxxxxxxx>


--
Geir Magnusson Jr 203-355-2219(w)
Adeptra, Inc. 203-247-1713(m)
geirm@xxxxxxxxxxx


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise