Forum:Multiple IF rows in a Table

Hey,

I'm having a bit of trouble putting together a table template, with parser functions for if certain rows should be displayed or not.

The template is here:.

Basically, the table is a "recipe" to make something, and the last part of it lists each ingredient and the quantity of that ingredient needed. At the moment, I've made it accept up to 6 ingredients. Each ingredient gets its own table-row, and two table-cells (the 1st is the item, the 2nd is the quantity). If the full 6 possible ingredients aren't given, then each un-needed table-row simply isn't displayed. I'm using   to determine if each row should be displayed.

The problem is, when less than 6 ingredients are supplied the template seems to get white-space (newlines I think) for the non-displayed rows. This produces a single row in the left-hand cell (with the text floating in the vertical-center) and 6 rows (as text or blank) in the right-hand cell.

When I try to manually remove the whitespace from the template, the whole table-rows for the ingredients becomes even worse.

Any ideas how to do this properly?

Thank you. :) --Defunc7 21:23, November 11, 2009 (UTC)


 * The simplest solution is porbably to use html tables instead of wikitables, to avoid the usage of . See Help:Tables and try to "revert" the wikitables back to html.  23:46, November 11, 2009 (UTC)


 * Took a look just now and could not see the effect you described. Maybe you fixed it already. For he sake of uniformity I'd make the first row conditional as well. If you think it makes sense then you could tie the heading row to the "ingr1 exists" condition.
 * I have not tried the HTML table option but I did persevere with wikitables and whilst is can be done and look very good it is indeed a headache because of two things.
 * the ! template being used in place of the pipe (|) character makes human checking/parsing/debug more challenging
 * use of the  parser function can cause extraneous new line characters if you are not careful about where you place closing bracket  characters and subsequent   parser function calls.
 * For a complex but working example see w:c:rappelz:Template:Skilltab which seems clsoe to the size of table you describe. It supports 0-6 rows and of course that can be expanded (another template applies the same conditional row concept but takes it to 28 rows of 21 columns).
 * There once was a time when the old pre-parser buffer limit would be reached and prevent further scaling but the new pre-processor (since maybe Oct/Nov last year) removed or significantly increased any limits on the scalability for such very large tables. I remember running a test case using the second link above and found that the next ceiling was hit at about 40-something rows. It depends on how many bytes you use in your various template parameters.
 * So, yes I agree that persisting with wikitables is a headache and few people are going to thank you for your success but it can be done if you are meticulous about matching up brackets and parentheses and if you keep an eye on newlilnes following an if# parser function.
 * --najevi 01:47, November 12, 2009 (UTC)