[ https://issues.apache.org/jira/browse/VELOCITY-944?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jakub Isakow updated VELOCITY-944: ---------------------------------- Priority: Critical (was: Major) > Macros in string literals are not resolved when local_scope is enabled > ---------------------------------------------------------------------- > > Key: VELOCITY-944 > URL: https://issues.apache.org/jira/browse/VELOCITY-944 > Project: Velocity > Issue Type: Bug > Components: Engine > Affects Versions: 2.0, 2.1, 2.2, 2.3 > Reporter: Jakub Isakow > Priority: Critical > > When local scope is enabled with > {noformat} > velocimacro.inline.local_scope=true > {noformat} > a template that is using a macro in string literal is not working correctly. > Example template: > {code} > #macro( m $v ) > <span>$v</span> > #end > #set($v = "#m('bar')") > $v > #m( 'foo' ) > {code} > Actual result: > {code} > #m('bar') > <span>foo</span> > {code} > Expected result: > {code} > <span>bar</span> > <span>foo</span> > {code} > The example template is working correctly for velocity 1.7. > After debugging a bit I think the problem might be caused by creating a new > Template instance in > [org.apache.velocity.runtime.parser.node.ASTStringLiteral#init|https://github.com/apache/velocity-engine/blob/2.3/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java#L145-L149]. > Because of that, when macro is being resolved, there is no macro instance > available in local scope (template instance) and it is rendered as string. > Locally I was able to make it work by using {{this.template}} when > {{context.getCurrentResource()}} returns {{null}}. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org