mustache/mustache.github.com

Handling recursion

lcsqlpete opened this issue · 1 comments

I'm working on a family tree project which currently builds it's html with a recursive php function. It starts with the oldest ancestor and processes family units, meaning husband/wife/children. Each child within a family unit could have it's own family unit and so on to an unknown depth.

The information for each individual is fixed and could be expressed as a Mustache template but I can't figure out how to handle the recursive and nesting aspects of the tree.

Has anyone come across this situation and solved it? It could apply to iother examples like bill-of-materials or org charts.

Thanks,
Pete

Recursive partials:

Partials begin with a greater than sign, like {{> box}}.
Partials are rendered at runtime (as opposed to compile time), so recursive partials are possible. Just avoid infinite loops.
...
In this way you may want to think of partials as includes, imports, template expansion, nested templates, or subtemplates, even though those aren't literally the case here.