Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rendering nested elements with an arbitrary depth using Chameleon ZPT

I am using Pyramid framework and I would like to render with Chameleon a html menu with nested lists (ul, li) of an arbitrary depth.

I cannot find some sort of recursive method in Chameleon in order to do so. It seems such a common need so I am wondering what is the right way of rendering nested elements with an arbitrary depth ?

But, there might be also some menu «widget» already available, fully tested and compatible with pyramid and Chamelon ?


1 Answers

<ul metal:define-macro="comment_list">
  <li tal:repeat="comment comments" class="comment" comment_id="${comment.id}">
    <div>ID: ${comment.id} ${comment.body}</div>
    <div tal:define="comments comment.children">
      <ul metal:use-macro="template.macros['comment_list']" />
    </div>
  </li>
</ul>
like image 190
bismigalis Avatar answered Jan 02 '26 02:01

bismigalis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!