Page 接口(interface)有一种方法可以直接用于迭代子项。
我想递归地迭代所有后续子项。
有一个重载方法 listChildren(Filter ,Boolean) 可以做到这一点......如何从视觉上调用这个方法? 我的意思是应该如何修改上面提到的标签以递归地执行它。
最佳答案
您可以定义 data-sly-template
,这是某种宏,然后使用 data-sly-call
递归调用它:
<template data-sly-template.descendants="${@ page}">
${page.title}
<ul data-sly-list.child="${page.listChildren}">
<li data-sly-call="${descendants @ page=child}"></li>
</ul>
</template>
<div data-sly-call="${descendants @ page=currentPage}" data-sly-unwrap></div>
关于recursion - 递归地列出Children,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27398309/