Details
-
Bug
-
Status: Open
-
Critical
-
Resolution: Unresolved
-
2.0, 2.1, 2.2, 2.3
-
None
-
None
Description
When local scope is enabled withÂ
velocimacro.inline.local_scope=true
a template that is using a macro in string literal is not working correctly.
Example template:
#macro( m $v ) <span>$v</span> #end #set($v = "#m('bar')") $v #m( 'foo' )
Actual result:
#m('bar')
<span>foo</span>
Expected result:
<span>bar</span> <span>foo</span>
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. 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.