You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Henning Schmiedehausen (JIRA)" <de...@velocity.apache.org> on 2007/03/08 01:10:28 UTC

[jira] Closed: (VELOCITY-5) Null AST error when calling a macro from within another macro

     [ https://issues.apache.org/jira/browse/VELOCITY-5?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henning Schmiedehausen closed VELOCITY-5.
-----------------------------------------


> Null AST error when calling a macro from within another macro
> -------------------------------------------------------------
>
>                 Key: VELOCITY-5
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-5
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.0-Release
>         Environment: Operating System: All
> Platform: PC
>            Reporter: Andriy Rozeluk
>         Assigned To: Velocity-Dev List
>
> Contact me for a better example if necessary, but it should be simple to 
> reproduce. If not, I can create one for you.
> Simply put, everything works fine in the default setup. I can call velocimacros 
> recursively and it's all great.
> Suppose, however, that in a particular framework, it was necessary to define 
> allow.inline.local.scope = true, because in this case we don't want everything 
> to be global.
> The call to a macro defined inline works correctly. However, if that macro, in 
> turn, wants to call another inline macro, I get this error:
> [error] VM error : nameOfMacro. Null AST
> Looks like it's an issue with defining what is local scope. There should be the 
> capability to have everything declared inline in a template to be able to call 
> everything in that template.
> So my code looks something like this:
> --myexample.vm--
> #macro( drawItem $item )
>   <!-- drawing item -->
> #end
> #macro( drawBundle $bundledraw )
>   <!-- drawing a bundle -->
>   #set( $bundleitems = $bundledraw.getItems() )
>   #foreach( $bundleitem in $bundleitems )
>     #drawItem( $bundleitem )
>   #end
> #end
> #macro( drawContainer $contdraw )
>   #set( $contitems = $contdraw.getItems() )
>   #foreach( $contitem in $contitems )
>     #if( ${utility.isItem( ${contitem} )} )
>       #drawItem( $contitem )
>     #elseif( ${utility.isBundle( ${contitem} )} )
>       #drawBundle( $contitem )
>     #else
>       <!-- invalid item -->
>     #end
>   #end
> #end
> #drawContainer( $container )
> --end test.vm--
> In the default velocity configuration, everything works as expected. The call 
> makes it from drawContainer to end up eventually calling drawItem. When 
> allow.inline.local.scope = true, however, the calls would break within 
> drawContainer, with drawItem and drawBundle generating the Null AST errors.
> I'm assuming that "local scope" means what I think it means - that everything 
> in a template should behave the same way as it would have if localscope were 
> false. The difference, of course, should only be that drawContainer, drawItem 
> and drawBundle are only available within this template, and not seen anywhere 
> else.
> I hope this helps somewhat. Again, contact me if you need a better example. 
> Thanks (btw: Velocity rocks! I love it!)

-- 
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