如何在Flask / Jinja中进行嵌套评论? [英] How to do nested comments in Flask/Jinja?
问题描述
预先感谢。
编辑:
我已经有了(来自API的)数据,并且注释是有孩子的对象。我只需要知道如何在Jinja递归呈现孩子。
使用宏,它们支持递归。 http://jinja.pocoo.org/docs/templates/#macros 编辑:for循环也支持递归,这也可以。 http://jinja.pocoo.org/docs/templates/#for
Like the comments in Hacker News and Reddit. I've looked at Jinja's docs but I can't find anything about recursion (which I assume is how this sort of thing is done). Any ideas?
Thanks in advance.
EDIT:
I already have the data (from an API), and the comments are objects which have children. I just need to know how to render the children recursively in Jinja.
Use macros, they support recursion. http://jinja.pocoo.org/docs/templates/#macros
Edit: for loops also support recursion, this would work as well. http://jinja.pocoo.org/docs/templates/#for
这篇关于如何在Flask / Jinja中进行嵌套评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!