Skip to content

Instantly share code, notes, and snippets.

@yangkun
Created July 2, 2015 02:33
Show Gist options
  • Save yangkun/5b9dc7c7220e67d2b9b1 to your computer and use it in GitHub Desktop.
Save yangkun/5b9dc7c7220e67d2b9b1 to your computer and use it in GitHub Desktop.
[velocity] print tree structure
#macro(menuTree $menus $url)
#set($macro.url = $url)
#foreach($m in $menus)
#set($macro.depth = ($m.Depth - 1) * 5)
<tr>
<td class="title">
${vstr.repeat('&nbsp;', $macro.depth)}
#if($m.Childs && $m.Childs.size() > 0) <i class="fa fa-minus-square-o"></i> #else <i class="fa fa-square-o"></i> #end
<a href="#">${m.Name}</a>
</td>
<td class="title"><a href="${siteUrl}$!{macro.url}/${m.Url}.htm" target="_blank">$!{macro.url}/${m.Url}</a><!-- ($m.Order) --></td>
</tr>
#if($m.Childs && $m.Childs.size() > 0) #adminMenuTree($m.Childs "$!{macro.url}/${m.Url}") #end
#end
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment