Template talk:Chart
Contents
How It Works[edit]
When I started with templates Chart seemed like magic. Now that I have experience I analyzed it and made some notes that I'll move to the Docs page or a sub-page later. If anything below is confusing please edit it.
Some of the template could be re-written but it works well and would be a waste of time to rewrite for only 6 unique charts.
This is one of the more difficult templates to understand on this site. Here are some notes on how it works internally.
Summary[edit]
{{Chart/start}} and {{Chart/end}} are HTML table tags. Each {{Chart}} is a table row. Each parameter to Chart is one of three things:
- a cell for connecting lines or spaces- unnamed parameter which must be (a single letter) or (a single letter and any number of non-characters like 'a315')
- a box for information- unnamed parameter which must be the name of a named parameter, referred to as 'box name' from now on
- a named parameter- names must contain at least one more letter somewhere after the first like 'MyName' or 'a3b15'
Each box is a 6 x 2 table and each cell is a 2 x 2 table with borders drawn where needed for that box or cell. Boxes are drawn all in the top template, cells use a sub-template for top and one for bottom. A cross using {{Chart/start}}{{Chart|+}}{{Chart/end}}
would look like this when expanded:
Chart/start: <table cellspacing="0" cellpadding="0" border="0" style=""> Chart (before cell): <tr align="center"> Chart/cell+t: <td style="border-right: 1px solid black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td> Chart (mid cell): </tr><tr align="center"> Chart/cell+b: <td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td> Chart (after cell): </tr> Chart/end: </table>
Each parameter to Chart is turned into a call to {{Chart/cellxx|namedvalue|border|boxstyle|rowspan|colspan}}
or {{Chart/box|namedvalue|border|boxstyle|rowspan|colspan}}
. For Chart/cell
the parameters are unused.
Breaking it down into component parts:
Check Unnamed Parameter Type[edit]
{{#ifeq:{{ucfirst:{{lc:{{{1}}}}}}}|{{uc:{{{1}}}}} |chart/cell{{{1|x}}}t or |chart/cell{{{1|x}}}b |chart/box or |x0 }}
If the unnamed parameter is the same when all upper-case as it is when only the first letter is upper-case then it's a cell and is called with Chart/cell(the letter used or x if blank)t
to draw the top half or Chart/cell(the letter used or x if blank)b
for the bottom half. If not then call {{Chart/box}} or {{X0}}. The Chart/box
code draws the entire box so the 'bottom half' makes a call to a null template to do nothing. This is necessary because this is being constructed inside {{ }} so an existing template must be used.
This only evaluates unnamed parameters. Named parameters are handled indirectly.
Indirect Named Value[edit]
|{{{{{{1}}}}}}
Pass the value of the named parameter given by the box name. Confused?
If {{{1}}}
= GrMa then pass the value of {{{GrMa}}}
. You must have used | GrMa = Grandma
later in the Chart call.
Indirect Named Box Parameters[edit]
|{{{border_{{{1}}}|{{{border|2}}}}}} |{{{boxstyle_{{{1}}}|{{{boxstyle|}}}}}} |{{{colspan_{{{1}}}|{{{colspan|6}}}}}} |{{{rowspan_{{{1}}}|{{{rowspan|2}}}}}}
These four parameters follow the same pattern. If the parameter name is specified and ends in the box name then use that. If not then check for a general parameter without the name and if that's also missing use the default value.
Example: If {{{1}}}
= GrMa then check for a border_GrMa
named parameter or a border
named parameter or use a default of 2.
colspan
and rowspan
that boxes are 6 x 2 tables so the default colspan is 6 and the default rowspan is 2.