Difference between revisions of "Template talk:T chart"

From Pathfinder Wiki
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
==Documentation==
 +
This template makes a T-chart with up to 6 rows (besides the header).  The first row is mandatory, as is the left column of each row that's present (the row is either displayed or not displayed depending on whether the left column entry is specified or not, regardless of whether the right column entry is or isn't).
 +
 +
===Parameters===
 +
*left_heading - this is the heading over the left column
 +
*right_heading heading over the right column
 +
*L1 - data for the left column, row 1
 +
*R1 - data for the right column, row 1
 +
To generalize...
 +
*L''n'' - data for the left column, row ''n''
 +
*R''n'' - data for the right column, row ''n''
 +
 +
===Example===
 
{{T chart
 
{{T chart
 
|left_heading=Fruit
 
|left_heading=Fruit
Line 9: Line 22:
 
|R3=Carrot
 
|R3=Carrot
 
}}
 
}}
 +
 +
Some of the coding for the template gets funky because you can't mix parser functions like <nowiki>{{#if:}}</nowiki> with vertical bars needed to separate table elements.  So anywhere we have <nowiki>{{!}}</nowiki> is a place where we cannot have a vertical bar (but need one).
 +
 +
===Bugs===
 +
The right column ends up with an extra blank line for every unused row.  If I don't put a carriage return between between the <nowiki>{{#if:}}</nowiki> functions, that goes away, but the the {{!}}- row separators break.  I've not figured a way around that yet.
 +
 +
I tried inserting a comment between the ifs with no break between, but that didn't work. :(
 +
 +
==Future changes==
 +
Might be able to make a row show up if either Ln or Rn are present by doing something like this:
 +
 +
<nowiki>
 +
{{#ifexpr: {{#len:{{{L2}}}}}+{{#len:{{{R2}}}}}|code for including the row|}}
 +
</nowiki>
 +
 +
the ifexpr has to have a numeric argument, so this approach sums the length of L2 and R2.  If it's 0, the expression is false.

Latest revision as of 02:59, 9 May 2020

Documentation

This template makes a T-chart with up to 6 rows (besides the header). The first row is mandatory, as is the left column of each row that's present (the row is either displayed or not displayed depending on whether the left column entry is specified or not, regardless of whether the right column entry is or isn't).

Parameters

  • left_heading - this is the heading over the left column
  • right_heading heading over the right column
  • L1 - data for the left column, row 1
  • R1 - data for the right column, row 1

To generalize...

  • Ln - data for the left column, row n
  • Rn - data for the right column, row n

Example

Fruit Vegetables
Banana Squash
Apple Radish
Orange Carrot


Some of the coding for the template gets funky because you can't mix parser functions like {{#if:}} with vertical bars needed to separate table elements. So anywhere we have {{!}} is a place where we cannot have a vertical bar (but need one).

Bugs

The right column ends up with an extra blank line for every unused row. If I don't put a carriage return between between the {{#if:}} functions, that goes away, but the the |- row separators break. I've not figured a way around that yet.

I tried inserting a comment between the ifs with no break between, but that didn't work. :(

Future changes

Might be able to make a row show up if either Ln or Rn are present by doing something like this:

{{#ifexpr: {{#len:{{{L2}}}}}+{{#len:{{{R2}}}}}|code for including the row|}}

the ifexpr has to have a numeric argument, so this approach sums the length of L2 and R2. If it's 0, the expression is false.