You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Nathan Bubna (JIRA)" <de...@velocity.apache.org> on 2008/08/15 05:09:44 UTC

[jira] Commented: (VELOCITY-532) $velocityCount in macro not processed

    [ https://issues.apache.org/jira/browse/VELOCITY-532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12622792#action_12622792 ] 

Nathan Bubna commented on VELOCITY-532:
---------------------------------------

Seems like this is likely to be related to VELOCITY-62.  There appears to have been some regression here from 1.4; i'm not sure what caused this change.

I would still like to note that i consider this bad practice.  If $velocityCount is relevant to the macro, it would be best passed in as an argument, rather than just hoping it is present.

> $velocityCount in macro not processed
> -------------------------------------
>
>                 Key: VELOCITY-532
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-532
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Will Glass-Husain
>             Fix For: 1.6
>
>
> ---------- Forwarded message ----------
> From: mraible <ma...@raibledesigns.com>
> Date: Mar 22, 2007 11:28 AM
> Subject: Issue with $velocityCount in 1.5
> To: user@velocity.apache.org
> I've been using Velocity 1.4 for a couple of years now with great success.
> Today, I tried to use Struts Menu 2.4.2 with Velocity 1.5 and found an issue
> with $velocityCount not being properly processed. My template is below.
> The problem occurs on the following line:
>         #if ($velocityCount == $menu.parent.components.size())
>           <li class="last">
>         #else
> With 1.4, $velocityCount turns into a number when the displayCssMenu macro
> is called from #foreach. However, in 1.5, it's never turned into a number.
> Any ideas?
> Thanks,
> Matt
> #macro( displayCssMenu $menu )
>   #if ($displayer.isAllowed($menu))
>     ## set menu title
>     #set ($title = $displayer.getMessage($menu.title))
>     #if (!$menu.url) #set ($url="javascript:void(0)") #else #set
> ($url=$menu.url) #end
>     ## create a single menu item
>     #if ($menu.components.size() == 0)
>         #if ($velocityCount == $menu.parent.components.size())
>           <li class="last">
>         #else
>           <li>
>         #end
>         #if ($menu.name == $currentMenu)
>            $url ${title}
>         #else
>            $url ${title}
>         #end
>     #else ## create multiple menu items in a menu
>         #if ($menu.components.size() > 0)
>             #set ($hasViewableChildren = false)
>             #foreach ($menuIt in $menu.components)
>                 #if ($displayer.isAllowed($menuIt))
>                     #set($hasViewableChildren = true)
>                 #end
>             #end
>         #end
>         <li#if ($hasViewableChildren) class="menubar"#end>
>            $url ${title}
>     #end
>     #if ($menu.components.size() > 0)
>         #if ($hasViewableChildren)
>           <ul>
>         #end
>         #foreach ($menuIt in $menu.components)
>             #displayCssMenu($menuIt)
>         #end
>         #if ($hasViewableChildren && ($velocityCount ==
> $menu.parent.components.size()))
>           </ul>
>         #else
>           </li>
>         #end
>     #else
>       </li>
>       #if ($velocityCount == $menu.parent.components.size())
>       </ul>
>       #end
>     #end
>   #end
> #end
> #displayCssMenu($menu)
> --
> View this message in context: http://www.nabble.com/Issue-with-%24velocityCount-in-1.5-tf3449438.html#a9621118
> Sent from the Velocity - User mailing list archive at Nabble.com.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
> -- 
> Forio Business Simulations
>  
> Will Glass-Husain
> wglass@forio.com
> www.forio.com

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