[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-dev
Subject:    [jira] Commented: (VELOCITY-652) Macros encountered in templates
From:       "Byron Foster (JIRA)" <dev () velocity ! apache ! org>
Date:       2009-01-24 11:51:59
Message-ID: 1673608488.1232797919568.JavaMail.jira () brutus
[Download RAW message or body]


    [ https://issues.apache.org/jira/browse/VELOCITY-652?page=com.atlassian.jira.plugi \
n.system.issuetabpanels:comment-tabpanel&focusedCommentId=12666895#action_12666895 ] 

Byron Foster commented on VELOCITY-652:
---------------------------------------

With the default settings there is no concept of scope and as soon as a macro is \
parsed, whether it is in a library or a template merge call, the macro becomes \
defined, and cannot be redefined.

I think the behavior that users expect is:

velocimacro.permissions.allow.inline.local.scope = true

Which would also give the results you expect in your example.  Like always, the \
documentation can be better.



> Macros encountered in templates are placed in global scope if no global library is \
>                 specified and \
>                 velocimacro.permissions.allow.inline.to.replace.global = false
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>  
> Key: VELOCITY-652
> URL: https://issues.apache.org/jira/browse/VELOCITY-652
> Project: Velocity
> Issue Type: Improvement
> Components: Engine
> Affects Versions: 1.6
> Reporter: Lauri Piispanen
> Priority: Minor
> Attachments: VelociMacroNamespaceTestCase.zip
> 
> 
> This is a minor issue and more of a documentation/implementation mismatch. With \
> default settings (allow.inline.to.replace.global=false, velocimacro.library not \
> specified etc.) the first time a velocimacro is encountered in a template, it is \
> placed in global scope and thus replaces all inline macros. Explicitly setting \
> "allow.inline.to.replace.global=true" will cure the issue, even though it should \
> have no effect as there are no global macros specified - hence nothing to replace! \
> Albeit this is a configuration documentation issue, the behavior can be quite \
> confusing and should probably be changed to have an empty global library if none is \
> specified. Steps to reproduce:
> 1) create new RuntimeInstance and only define the resource loader in properties 
> 2) create two templates, named test1.vtl and test2.vtl:
> --- test1.vtl:
> #macro( myMacro )
> Macro A
> #end
> #myMacro()
> --- test2.vtl:
> #macro( myMacro )
> Macro B
> #end
> #myMacro()
> 3) first merge() test1.vm, should return "Macro A" (and it does)
> 4) now merge() test2.vm, should return "Macro B" but returns "Macro A" instead
> 5) create new RuntimeInstance with \
> "velocimacro.permissions.allow.inline.to.replace.global = true" 6) retry merging \
> and observe correct behavior

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic