Difference between revisions of "Template:Tree"
m (13 revisions imported: Initial import from smithfam) |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 6: | Line 6: | ||
* ''start depth'': What depth to consider the root to be at; default is 1 | * ''start depth'': What depth to consider the root to be at; default is 1 | ||
* ''skip root'': Whether the root of the tree should be skipped; if set, the root's children have the start depth | * ''skip root'': Whether the root of the tree should be skipped; if set, the root's children have the start depth | ||
| − | </noinclude><includeonly>{{#if:{{{skip root|}}} | + | </noinclude><includeonly>{{#if:{{{1|}}} |
| + | | {{#if: {{#ifexist: {{{children}}} | yes}}{{#ifexist: Template:{{{children}}} | yes}} | ||
| + | | {{#if:{{{skip root|}}} | ||
| {{Tree/Children|{{{2|, }}}|| | | {{Tree/Children|{{{2|, }}}|| | ||
| current parent={{{1}}} | | current parent={{{1}}} | ||
| Line 22: | Line 24: | ||
| children={{{children}}} | | children={{{children}}} | ||
}} | }} | ||
| − | }}</includeonly> | + | }} |
| + | | {{#if:{{{skip root|}}}||{{{{{template}}}|{{{1}}}| depth={{#if:{{{start depth|}}}|{{{start depth}}}|1}} | index=1}}}} | ||
| + | }}}}</includeonly> | ||
Latest revision as of 12:11, 7 December 2015
Apply a template to a string, and then recursively apply this template to each "child", as defined by a function.
- First parameter: Root of the tree
- Second parameter: Delimiter used to separate each application of the template; default is comma+space
- template: Template to apply to each node (first parameter is the node; depth and index are the tree coordinates, 1-based)
- children: Function mapping a parent to children (first parameter is the node; depth and index are the tree coordinates of the child, 1-based; empty result indicates no more children)
- start depth: What depth to consider the root to be at; default is 1
- skip root: Whether the root of the tree should be skipped; if set, the root's children have the start depth