velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthias Hendler <>
Subject Re: Are inline macros cached somewhere?
Date Mon, 28 Aug 2006 13:24:58 GMT

I think that in velocity all macros have a global scope.
So whenever you define a macro it will by put in this global area. And I 
would expect that velocity doesn't parse an "already known" macro twice 
for performance reasons.

What can you do?
Define one macro with a second parameter to determine the scope 
Before the parse you set a global variable which helds the actual scope.
In your RequestView you call the macro with this global variable.
Define a macro like:

#macro( requestAction $id $scope )
#if ("user".equals($scope)
	<user actions>
	<vendor actions>

In your user view:
#set ($GlobalActualScope = "user")

In your requestView call the macro like:
requestAction $actualId $GlobalActualScope

Waiting for an expert what he says. ;-)

Anton Tonchev schrieb:

>I have the following problem:
>I have two pages userRequests.vm and vendorRequests.vm.
>The first one has userRequests.vm:
>#macro( requestItemActions $requestId )
>        <user specific actions>
>And the second one vendorRequests.vm:
>#macro( requestItemActions $requestId )
>        <vendor specific actions>
>The file that is included (includes/requestView.vm) contains an
>interation over some items and calls the macro requestItemActions for
>each item.
>The problem is that the inline defined macro is somewhat cached
>because after the first parse of the temlate it is remambered and in
>both pages (vendorRequest.vm and userRequest.vm) is used the same
>Do you have any idea why it is not working?
>I tried with the
>but it still isn't working.
>Thanks in advance.
>To unsubscribe, e-mail:
>For additional commands, e-mail:

Mit freundlichen Grüßen

Matthias Hendler


Konrad-Zuse-Str. 1
18184 Roggentin

Telefon: +49 (0)3 81 / 25 24 - 0
Telefax: +49 (0)3 81 / 25 24 - 4 99

This email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity
to whom they are addressed. The views expressed in this
e-mail are those of the individual author and not necessarily
those of SIV.AG.

This footnote also confirms that this email message has
been swept by serval anti-virus tools for the presence
of computer viruses.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message