velocity宏命令定义
程序员文章站
2022-05-02 20:28:16
...
#macro(includeChilds $page $withPageBreaks)
#includeChildren($page $withPageBreaks)
#end
## Macro to include children at multiple levels
#macro(includeChildren $page $withPageBreaks)
#if($clevel!=0)
#foreach($childDocName in $xwiki.searchDocuments("where doc.parent='$page' order by doc.creationDate"))
#set($childDoc = $xwiki.getDocument($childDocName))
#if(($childDoc)&&($childDoc.getSpace()!="Panels")&&($childDoc.getSpace()!="XWiki"))
#if($withPageBreaks)
#pagebreak()
#end
$childDoc.getRenderedContent()
#set($clevel = $xwiki.add($clevel,-1))
#includeChildren($childDocName $withPageBreaks)
#set($clevel = $xwiki.add($clevel,1))
#end
#end
#end
#end
调用方式:
#includeChilds('page' 'withPageBreaks')