Template:Tree chart: Difference between revisions

From Wikibundi
m (Reverted edits by Arbundi (talk) to last revision by [[User:Wiki>Trialpears|Wiki>Trialpears]])
Tags: Replaced Rollback
No edit summary
 
Line 1: Line 1:
<includeonly>{{#invoke:Tree chart|main}}</includeonly><noinclude>{{documentation}} </noinclude>
<!-- Template:Tree chart -->
{{#vardefine:__out|}}
<!-- helper: produce cell content (compare the cell token to known label names and substitute if provided) -->
{{#macro:mapCell|{{{1|}}}|{{{GrMa|}}}|{{{GRP|}}}|{{{MOM|}}}|{{{DAD|}}}|{{{DAISY|}}}|{{{JOE|}}}|{{{ME|}}}|{{{SIS|}}}}}
<!-- ^ we call this below for each position 1..11 -->
 
<!-- internal parser function definition (works by multiple #ifeq checks). -->
{{#switch: {{{1|}}}
  | GrMa = {{{GrMa|GrMa}}}
  | GRP  = {{{GRP|GRP}}}
  | MOM  = {{{MOM|MOM}}}
  | DAD  = {{{DAD|DAD}}}
  | DAISY= {{{DAISY|DAISY}}}
  | JOE  = {{{JOE|JOE}}}
  | ME  = {{{ME|ME}}}
  | SIS  = {{{SIS|SIS}}}
  | {{{1|}}} = {{{1|}}}
}}
 
<!-- The actual row renderer -->
<tr>
  {{#for|i=1|i<=11|i=i+1}}
    {{#switch: {{{!}}} }}
    <!-- we will render each cell by expanding the corresponding positional parameter -->
  {{#vardefine:tmp|{{{${i}|}}}}}
  {{#if: {{{#vardefine:tmp|{{{${i}|}}}}} }} <!-- if not empty -->
    {{#set:cellval|{{{${i}|}}}}}
  {{#else}}
    {{#set:cellval|}}
  {{#endif}}
  {{#if: {{{#var:cellval}}} }}
    <!-- produce class / content based on token -->
    {{#switch: {{#var:cellval}}
        | - = <td><div class="tc-piece tc-horiz"></div></td>
        | | = <td><div class="tc-piece tc-vertline"></div></td>
        | ~ = <td><div class="tc-piece tc-vert"></div></td>
        | y = <td><div class="tc-piece tc-down"></div></td>
        | + = <td><div class="tc-piece tc-plus"></div></td>
        | . = <td><div class="tc-piece tc-dot"></div></td>
        | ( = <td><div class="tc-piece tc-lcorner"></div></td>
        | ) = <td><div class="tc-piece tc-rcorner"></div></td>
        | default = <td><div class="tc-piece tc-text">{{#switch: {{#var:cellval}}
              | GrMa = {{{GrMa|GrMa}}}
              | GRP  = {{{GRP|GRP}}}
              | MOM  = {{{MOM|MOM}}}
              | DAD  = {{{DAD|DAD}}}
              | DAISY= {{{DAISY|DAISY}}}
              | JOE  = {{{JOE|JOE}}}
              | ME  = {{{ME|ME}}}
              | SIS  = {{{SIS|SIS}}}
              | #default = {{{#var:cellval}}}
            }}</div></td>
      }}
  {{#else}}
    <td><div class="tc-piece tc-empty"></div></td>
  {{#endif}}
  {{/for}}
</tr>
 
<!-- NOTE: due to limited pure-wikitext looping/scripting portability, the above uses
    the parser functions available on many wikis (ParserFunctions and #for/#switch support).
    If your wiki lacks "#for" or "#switch" you can expand the 11 cells manually (copy/paste).
-->

Latest revision as of 22:38, 6 October 2025

{{#vardefine:__out|}} {{#macro:mapCell|||||||||}}


{{#for|i=1|i<=11|i=i+1}} {{#vardefine:tmp|}} {{#else}} {{#endif}} {{#else}}

 {{#endif}}
 Template:Tree chart/for