velocity-user mailing list archives

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

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 
(user/vendor).
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>
#else
	<vendor actions>
#end
#end


In your user view:
#set ($GlobalActualScope = "user")
#parse("includes/requestView.vm")

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


Waiting for an expert what he says. ;-)
Matthias



Anton Tonchev schrieb:

>Hello!
>
>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>
>#end
>#parse("includes/requestView.vm")
>-----------------
>
>And the second one vendorRequests.vm:
>#macro( requestItemActions $requestId )
>        <vendor specific actions>
>#end
>#parse("includes/requestView.vm")
>------------------
>
>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
>template.
>
>Do you have any idea why it is not working?
>
>I tried with the
>velocimacro.permissions.allowInlineToOverride=true
>but it still isn't working.
>
>Thanks in advance.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>  
>


-- 
Mit freundlichen Grüßen

Matthias Hendler

Technologie

SIV.AG
Konrad-Zuse-Str. 1
18184 Roggentin

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




mailto:matthias.hendler@siv.de
http://www.siv.de



**********************************************************************
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: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message