我有一个树状的注释结构,我想在 Ember CLI 中使用 Handlebars 来渲染。每个评论都可以有无限组回复,每个回复都有无限数量的回复,就像你在 Reddit 上一样。我有以下文件“comments.hbs”。
<div class="comments">
{{#each comments}}
<div class="comment">
<span><b>{{author}}</b></span> <span>{{showdown-addon text}}</span>
</div>
{{recursively-call-this-template-somehow-with-new-context replies}}
{{/each}}
</div>
有人知道如何使用 Ember CLI 做到这一点吗?我见过一些使用 {{> template-name}} 的解决方案,但尚未成功运行。
最佳答案
一种方法是使用 ArrayController
,如果回复列表可用,它会再次呈现自身。
关于javascript - 使用 Ember CLI 递归渲染 Handlebars 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27082749/