Recently a cascading style sheets (CSS) "hack" known more generally as "hiddenStructure" has seen widespread use on Wikipedia. This hack makes it possible to conditionally hide rows of data in tables dependent upon whether or not certain parameters are passed (or are/aren't empty/blank).
Problems
The problem with using hiddenStructure is that it hides rows in a non-standard way. Whereas other websites hide data by simply not sending it out from the server[1], hiddenStructure defers this hiding process to the client. Because of this, some non-CSS aware or compliant browsers incorrectly render pages using this hack (see pictures at right).
Some pages minimize the damage by only displaying the variable if it's actually non-blank (using the syntax {{{variable|}}}
). In this way only the row is displayed, not the ugly {{{variable}}} variable name. Of course in templates with large numbers of conditional rows, this still results in unnecessary data being displayed to non-CSS compliant browsers.
Because of these problems many articles render poorly for the disabled. In the worst case, a number of Wiki-markup variables are displayed/read to the reader. In the best case, a number of rows are displayed/read which are empty. For these reasons, hiddenStructure should not be used.
Solutions
- Use meta-templates such as {{qif}} to conditionally display data.
- Use Weeble code (such as {{row}}).
- Limit or eliminate conditional rows.
Other possible solutions, which are ill-advised, include:
- Breaking apart a single template into various multiple other templates, with each handling different combinations of parameters.
- Problem: This is a maintenance nightmare, and goes against the purpose of templates (centralizing maintenance to one place).
Notes
- ^ Most servers use PHP or ASP to conditionally send data from the server. More advanced designs cache results so PHP/ASP scripts are only executed once for each possible outcome.
See also
- Wikipedia:HiddenStructure
- Wikipedia:Avoid using meta-templates (deprecated/rejected)