Extension:TableData

TableData implements a, , and   attributes can optionally define the name of a template to use to format the header, individual rows, and the footer.

Examples
This defines a simple table with no borders: attribute to the tabledata tag:
 * format=csv
 * The csv format expects comma-separated values formatted data with a comma as a separator and php's default handling of " as an enclosure and \ as an escape.


 * format=separated
 * The separated data format expects an extra separator attribute to be defined.
 * Valid separators are:
 * space: Single spaces (not multiple)
 * tab: A single tab (not multiple)
 * whitespace: Multiples of any whitespace such as spaces and tabs
 * comma: Commas ",". Note that this is not the same as csv which uses a csv parser that supports quoting commas inside values you cannot quote or escape commas in the separated format
 * colon: A single colon ":"
 * semicolon: A single semicolon ";"

Templates
The,  , and   attributes can be used to define the name templates to use to format the header, individual rows, and the footer of the table (or something else if you decide to override them all and output something different).

Typically you should define a simple table header in the header: If you are just customizing the formatting of the table you usually don't need to override the footer, unless you are creating something other than a table, or want to add table headers to the footer.

Parameters
Each of these templates are passed a number of parameters to allow them to output and format the data.

The table data of a row is passed into the row template in parameters named by the header they are associated with. So in the above examples the value of the Format column for a row would be included into the template using a. Additionally the row template can output the number of the current table row using  the value of this number starts at 1 for the first row.

For all templates, the header, footer, and row templates the names of the headers are included inside of  parameters where   is the first header,   is the second, and so on.

Note that because the names of headers are passed as arguments to the row template it becomes possible to hack in generic formatting templates (with a limited number of columns) by using a trick like  to output the contents of the first header and so on.

This template setup makes table data based tables very flexible. You can define fairly generic table formats to be used for data by using the  parameters to output header names, and the   trick to output table cells in header order. Or for more complex data you can define custom header, row, and footer templates with header names hardcoded in the templates and use the headers inside of the data table to define a clean set of parameters that the data should be exposed to the row templates with to make custom formatted data that previously took a lot of direct template inclusions much simpler.

Beta
There are one or two things not yet implemented in the extension.
 * A hook to allow extensions to define parsers for new input data formats.
 * The CSV parser needs some extra code to be compatible with php < 5.3 which does not have str_getcsv but has fgetcsv.

Alternatives

 * Extension:SimpleTable