Difference between revisions of "Template:Tree/Children"

From Green Family Wiki
Jump to: navigation, search
m (17 revisions imported: Initial import from smithfam)
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
<noinclude>Apply [[Template:Tree/Subtree]] to the given child and then recursively apply this to the next child, as determined by a function.
+
<noinclude>Apply [[Template:Tree/Subtree]] to the given child and then recursively apply this template to the next child, as determined by a function.
 
* First parameter: Delimiter to prefix future nodes
 
* First parameter: Delimiter to prefix future nodes
 
* Second parameter: Current delimiter to prefix current child
 
* Second parameter: Current delimiter to prefix current child
Line 7: Line 7:
 
* ''index'': i, where the current child is the ith child of the current parent
 
* ''index'': i, where the current child is the ith child of the current parent
 
* ''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 result 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)
</noinclude><includeonly>{{Select|{{{2}}}|
+
</noinclude><includeonly>{{Select|{{{2}}}| param={{#if: {{{current child}}}|1}}}}{{#if: {{#iferror: {{{current child}}}}}
| param={{#if: {{{current child}}} | 1}}
+
| {{Tree/Subtree|{{{1}}}|
}}{{#ifexpr: {{{depth}}} > 4 or {{{index}}} > 4
 
| ...({{{depth}}}/{{{index}}})...
 
| {{#if: {{{current child}}}
 
| {{Tree/Subtree|{{{1}}}|{{{1}}}|
 
 
   | current parent={{{current child}}}
 
   | current parent={{{current child}}}
 
   | depth={{{depth}}}
 
   | depth={{{depth}}}
Line 21: Line 17:
 
   }}{{Tree/Children|{{{1}}}|{{{1}}}|
 
   }}{{Tree/Children|{{{1}}}|{{{1}}}|
 
   | current parent={{{current parent}}}
 
   | current parent={{{current parent}}}
   | current child={{{{{children}}}|{{{current parent}}}|{{#expr:{{{index}}}+1}}
+
   | current child={{{{{children}}}|{{{current parent}}}| depth={{{depth}}} | index={{#expr:{{{index}}}+1}}}}
 
   | depth={{{depth}}}
 
   | depth={{{depth}}}
 
   | index={{#expr:{{{index}}}+1}}
 
   | index={{#expr:{{{index}}}+1}}
Line 27: Line 23:
 
   | children={{{children}}}
 
   | children={{{children}}}
 
   }}
 
   }}
}}}}</includeonly>
+
}}</includeonly>

Latest revision as of 12:11, 7 December 2015

Apply Template:Tree/Subtree to the given child and then recursively apply this template to the next child, as determined by a function.

  • First parameter: Delimiter to prefix future nodes
  • Second parameter: Current delimiter to prefix current child
  • current parent: Parent of the current child
  • current child: Child to produce a subtree for; terminates if empty
  • depth: Depth of the current child
  • index: i, where the current child is the ith child of the current parent
  • 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)