TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Recursive KOstache
  • Incase you missed the title I am using KOstache, and trying to figure out recursive partials.

    I have a recursive partial called folderlist:


    <li>
    <a href="{{url}}">{{folder}}</a>
    <ul>
    {{#sub_folders}}
    {{>folderlist}}
    {{/sub_folders}}
    </ul>
    </li>


    But it rolls into an everlasting loop because of scoping issues, basically inside the second level folderlist, even if that loop does not have sub_folders set, it then goes up the scope chain and finds the sub_folders of the first level.

    http://mustache.github.com/mustache.5.html says you can have recursive partials, am I doing something wrong?

    My array is something like:

    array(
    'folder' => 'a parent folder',
    'url' => '/',
    'sub_folders' => array(
    'folder' => 'a sub folder',
    'url' => '/sub',
    )
    )


    Occasionally it gets deeper too. Any ideas?
  • I've done this in Vendo for product categories. Check it out.
  • FECKING AWESOME. Lol, thanks Jeremy!

    <li>
    <a href="{{url}}">{{folder}}</a>
    {{#has_sub_folders}}
    <ul>
    {{#sub_folders}}
    {{>folderlist}}
    {{/sub_folders}}
    </ul>
    {{/has_sub_folders}}
    </li>

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion