Template:Clade example

From blackwiki
Revision as of 07:58, 3 August 2018 by imported>Jts1882 (add second row, but still have problem of using parameter without parsing it)
Jump to navigation Jump to search
Template code Resulting output
label

leaf1

leaf2

label

leaf1

leaf2

second row second row
Template documentation[view] [edit] [history] [purge]

Template:Uses Lua


Template code Resulting output
{{clade
|label1=label 
|1={{clade 
   |1=leaf1 
   |2=leaf2 
   }}
}}
{{clade
|label1=label 
|1={{clade 
   |1=leaf1 
   |2=leaf2 
   }}
}}

This template is designed to aid writing documentation of the {{clade}} by showing examples of code and the executed output, with option description and comment. It creates a table with four columns:

  • a description of what the example in the row shows
  • the code wrapped in <pre> tags,
  • the executed code, and
  • a comment on the example
Template code Resulting output
{{clade
|label1=label 
|1={{clade 
   |1=leaf1 
   |2=leaf2 
   }}
}}
{{clade
|label1=label 
|1={{clade 
   |1=leaf1 
   |2=leaf2 
   }}
}}

Selecting columns. Columns may be omitted optionally. The columns to be shown are indicated by the following four parameters.

  • |description= indicates that the description column should be shown. If used with a value it will set the header (default: Description).
  • |code= indicates that the code column should be shown. A value will be used as the header (default: Code).
  • |output= indicates that the output column should be shown. A value will be used as the header (default: Output).
  • |comment= indicates that the comment column should be shown. A value will be used as the header (default: Commment).

Omitting the parameter omits the column. For instance, just using |code= and |output= just shows the code and output (as shown on the right).


Content of rows. The content of the rows is used using the parameters with a numerical suffix indicating the row number:

    • |description1= contains text describing the example in the first row. Similarly for |description2= ... |descriptionN.
    • |code1= contains the clade code for the first row wrapped <pre> tags.
    • |output1= contains the transcluded output of the clade code.
    • |comment1= contains a comment


Other options:

  • |align= left | right | center

A more complex example:

{{Clade example |align=left |description= |code= |output= |comment= |description1=Simple clade element |code1=<pre>{{clade |label1=Label |1={{clade |1=Leaf A |2=Leaf B }} }}</pre> |output1={{clade |label1=Label |1={{clade |1=Leaf A |2=Leaf B}} }} |comment1=Two child elements |description2=A more complex clade structure |code2=<pre>{{clade |label1=Label |1={{clade |1=Node A (terminal) |label2=Node B |sublabel2=(internal) |2={{clade |1=Leaf 1 |2=Leaf 2 }} }} }}</pre> |output2={{clade |label1=Label |1={{clade |1=Node A (terminal) |label2=Node B |sublabel2=(internal) |2={{clade |1=Leaf 1 |2=Leaf 2 }} }} }} |comment2=Two levels. The second clade element is nested in the first. |description3=description 3|code3=code 3 |output3=output 3 |comment3=comment 3 |description4=description 4|code4=code 4 |output4=output 4 |comment4=comment 4 }}

Template code Resulting output
{{clade
|label1=Label
|1={{clade 
   |1=Leaf A 
   |2=Leaf B
   }}
}}
{{clade
|label1=Label
|1={{clade 
   |1=Leaf A 
   |2=Leaf B
   }}
}}
{{clade
|label1=Label
|1={{clade 
   |1=Node A (terminal)
   |label2=Node B
   |sublabel2=(internal)
   |2={{clade
      |1=Leaf 1
      |2=Leaf 2
      }}
   }}
}}
{{clade
|label1=Label
|1={{clade 
   |1=Node A (terminal)
   |label2=Node B
   |sublabel2=(internal)
   |2={{clade
      |1=Leaf 1
      |2=Leaf 2
      }}
   }}
}}