Image macro inside a recursive macro doesn't work for the first call

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Image macro inside a recursive macro doesn't work for the first call

Tiago Rinck Caveden
Hello,

I have a recursive velocity macro that calls the Image macro provided by
XWiki. Weirdly, the call doesn't work only for the first call of this
recursive function. All the subsequent ones (the really "recursive" calls)
render the image perfectly. For the first call what's rendered is the code
that calls the image macro, with the brackets and everything, as if I had
escaped it somehow.

Does anyway has any idea of what is happening?

Maybe it helps if you can see the code, so here it goes. The calls to my
macro and to the image macro are in bold:

#macro (createChildrenNodes $parentNodeName $childrenSkillList)
    #foreach ($skill in $childrenSkillList)

      #set ($iconStyleClass = "ygtv")
      #if($velocityCount == $childrenSkillList.size())
        #set($iconStyleClass = $iconStyleClass + "l")
      #else
        #set($iconStyleClass = $iconStyleClass + "t")
      #end
      #if ($skill.hasChildren)
         #set($iconStyleClass = $iconStyleClass + "p")
      #else
         #set($iconStyleClass = $iconStyleClass + "n")
      #end

      var node$skill.id = new YAHOO.widget.HTMLNode('<table border=0
cellpadding=0 cellspacing=0><tr><td><div
class="$iconStyleClass"></div></td><td><a href="./EditSkill?skillId=$
skill.id">$skill.name</a>&nbsp;&nbsp;<a
href="./DefiningExistentSkills?do=delete&skillId=$skill.id">*{image:supprimer.bmp|13|alt=Click
to delete skill $skill.name}*</a></td></tr></table>', $parentNodeName,
true);
      *#createChildrenNodes("node$skill.id" $skill.children)*

    #end
  #end

  function treeInit()
  {
    var tree = new YAHOO.widget.TreeView("treeview");
    var root = tree.getRoot();
    *#createChildrenNodes('root' $xwiki.cartography.getSkillTree())*
    tree.draw();
  }
  treeInit();


Thanks,
--
Tiago Rinck Caveden
http://caveden.multiply.com
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Tiago Rinck Caveden
http://caveden.multiply.com
Reply | Threaded
Open this post in threaded view
|

Re: Image macro inside a recursive macro doesn't work for the first call

Tiago Rinck Caveden
I forgot to mention that the problem is in the first call of the image macro
inside my macro only. I tried calling the image macro before and after the
call to my recursive macro, and in both cases it worked without any
problems.

On Fri, May 30, 2008 at 4:57 PM, Tiago Rinck Caveden <[hidden email]>
wrote:

> Hello,
>
> I have a recursive velocity macro that calls the Image macro provided by
> XWiki. Weirdly, the call doesn't work only for the first call of this
> recursive function. All the subsequent ones (the really "recursive" calls)
> render the image perfectly. For the first call what's rendered is the code
> that calls the image macro, with the brackets and everything, as if I had
> escaped it somehow.
>
> Does anyway has any idea of what is happening?
>
> Maybe it helps if you can see the code, so here it goes. The calls to my
> macro and to the image macro are in bold:
>
> #macro (createChildrenNodes $parentNodeName $childrenSkillList)
>     #foreach ($skill in $childrenSkillList)
>
>       #set ($iconStyleClass = "ygtv")
>       #if($velocityCount == $childrenSkillList.size())
>         #set($iconStyleClass = $iconStyleClass + "l")
>       #else
>         #set($iconStyleClass = $iconStyleClass + "t")
>       #end
>       #if ($skill.hasChildren)
>          #set($iconStyleClass = $iconStyleClass + "p")
>       #else
>          #set($iconStyleClass = $iconStyleClass + "n")
>       #end
>
>       var node$skill.id = new YAHOO.widget.HTMLNode('<table border=0
> cellpadding=0 cellspacing=0><tr><td><div
> class="$iconStyleClass"></div></td><td><a href="./EditSkill?skillId=$
> skill.id">$skill.name</a>&nbsp;&nbsp;<a
> href="./DefiningExistentSkills?do=delete&skillId=$skill.id">*{image:supprimer.bmp|13|alt=Click
> to delete skill $skill.name}*</a></td></tr></table>', $parentNodeName,
> true);
>       *#createChildrenNodes("node$skill.id" $skill.children)*
>
>     #end
>   #end
>
>   function treeInit()
>   {
>     var tree = new YAHOO.widget.TreeView("treeview");
>     var root = tree.getRoot();
>     *#createChildrenNodes('root' $xwiki.cartography.getSkillTree())*
>     tree.draw();
>   }
>   treeInit();
>
>
> Thanks,
> --
> Tiago Rinck Caveden
> http://caveden.multiply.com




--
Tiago Rinck Caveden
http://caveden.multiply.com
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Tiago Rinck Caveden
http://caveden.multiply.com