How to make a resursion call for #invoke in #define?

I am using xamin handlebars WordPress plugin and I want to call #invoke helper function recursively.

Link to handlebars plugin: https://github.com/mardix/Handlebars

This is how render_menu should be define:

{{#define menu}}
    <li>
        {{label}}
        {{#if submenu}}
            <ul>
                {{#each submenu}} 
                    {{#invoke menu}}
                {{/each}}
            </ul>

        {{/if}}
    </li>
{{/define}}

And I should invoke it by:

<ul>
{{#each menus}}
     {{#invoke menu}}
  {{/each}}
</ul>

Read more here: How to make a resursion call for #invoke in #define?

Leave a Reply

Your email address will not be published. Required fields are marked *