Recursion in Liquid Markup / Liquid Templates

I was trying to figure out how I am going to do a recursion with Liquid . I have an application where I want to give users full control over the display of the menu. However, the menu is defined by the tree, which means the need for recursive functions in Liquid.

How can i do this? After some reading, I thought I would do it this way:

turn on

I thought about using it includeas follows:

<ul id='site_nav' class='nav'>
  {{ include 'menu_item' with menu_items }}
</ul>

And the partial menu_item menu is as follows:

<li id='{{menu_item.dom_id}}' class='{{menu_item.css_menu_class}}'>
  {{ menu_item.name }}
  <ul>
    {{ include 'menu_item' with menu_item.children }}
  </ul>
</li>

However, since it is editable, I need to hack Liquid so that it downloads partial files from the database. Since it will take much longer to study, I would like to first ask if anyone has solved this problem before.

  • , - ?
  • , ? ?

!

+5

All Articles