Template:Tree: Difference between revisions

From Smith Family Wiki
Jump to navigation Jump to search
No edit summary
(Undo revision 253 by Dan Smith (talk))
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
<noinclude>Apply a template to a string, and then recursively apply this function to each "child", as defined by a function.
<noinclude>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
* First parameter: Root of the tree
* Second parameter: Delimiter used to separate each application of the template; default is comma+space
* 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)
* ''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; second parameter is the requested index, 1-based; empty indicates no more children)
* ''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)
* ''skip root'': Whether the root of the tree should be skipped; if so, the root's children have depth 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
</noinclude><includeonly>{{#if:{{{1|}}}
</noinclude><includeonly>{{#if:{{{1|}}}
| {{Tree/Subtree|{{{2|, }}}||
| {{#if: {{#ifexist: {{{children}}} | yes}}{{#ifexist: Template:{{{children}}} | yes}}
   | currentparent={{{1|}}}
| {{#if:{{{skip root|}}}
   | skip={{{skip root|}}}
| {{Tree/Children|{{{2|, }}}||
   | depth=1
   | current parent={{{1}}}
   | count=1
   | current child={{{{{children}}}|{{{1}}}| depth={{#if:{{{start depth|}}}|{{{start depth}}}|1}} | index=1 }}
   | template={{{template|}}}
   | depth={{#if:{{{start depth|}}}|{{{start depth}}}|1}}
   | children={{{children|}}}
   | index=1
   | template={{{template}}}
   | children={{{children}}}
   }}
   }}
}}</includeonly>
| {{Tree/Subtree|{{{2|, }}}|
  | current parent={{{1}}}
  | depth={{#if:{{{start depth|}}}|{{{start depth}}}|1}}
  | index=1
  | template={{{template}}}
  | children={{{children}}}
  }}
}}
| {{#if:{{{skip root|}}}||{{{{{template}}}|{{{1}}}| depth={{#if:{{{start depth|}}}|{{{start depth}}}|1}} | index=1}}}}
}}}}</includeonly>

Latest revision as of 10:47, 18 June 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