Difference between revisions of "Template:Tree"

From Green Family Wiki
Jump to: navigation, search
(Created page with "<noinclude>Apply a template to a string, and then recursively apply this function to each "child", as defined by a function. * First parameter: Root of the tree * Second param...")
 
Line 5: Line 5:
 
* ''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; second parameter is the requested index, 1-based; empty indicates no more children)
 
* ''skip root'': Whether the root of the tree should be skipped; if so, the root's children have depth 1
 
* ''skip root'': Whether the root of the tree should be skipped; if so, the root's children have depth 1
</noinclude><includeonly>{{Tree/Subtree|{{{2|, }}}||
+
</noinclude><includeonly>{{#if:{{{1|}}}
| currentparent={{{1|}}}
+
| {{Tree/Subtree|{{{2|, }}}||
| skip={{{skip root|}}}
+
  | currentparent={{{1|}}}
| depth=1
+
  | skip={{{skip root|}}}
| count=1
+
  | depth=1
| template={{{template|}}}
+
  | count=1
| children={{{children|}}}
+
  | template={{{template|}}}
 +
  | children={{{children|}}}
 +
  }}
 
}}</includeonly>
 
}}</includeonly>

Revision as of 20:27, 15 June 2015

Apply a template to a string, and then recursively apply this function 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; second parameter is the requested index, 1-based; empty indicates no more children)
  • skip root: Whether the root of the tree should be skipped; if so, the root's children have depth 1