summaryrefslogtreecommitdiff
path: root/doc/plugins/contrib/table.mdwn
blob: 46f7b09a78ccf873a42ac69e3dbc31e4f4cec5ac (plain)

[[template id=plugin name=table author="[[VictorMoral]]"]] [[tag type/format]]

This plugin supplies a table [[PreprocessorDirective]] to build html tables from data in CSV (comma-separated values) or DSV (delimiter-separated values) format.

It needs the perl module [[cpan Text::CSV]] for the CSV data.

Usage

In any source page include the following:

The next table shows the results:

\[[table class="myclass" format=dsv data="""
Custom|Amount|
Fulanito|134,34|
Menganito|234,56|
"""]]

This is my last acquisition:

[[table class="book_record" format=csv file="data/books/record1"]]

And the record1 page should be similar to:

"Title","Perl Best Practices"
"Author","Damian Conway"
"Publisher","O’Reilly"

The parameters are:

  • data: Values for the table
  • file: Wiki page containing the data.
  • format (optional): format name of the data. By default is auto and the options are csv or dsv.
  • delimiter (optional): The character used to separate fields. By default, DSV format uses a pipe (|), and CSV uses a comma (,).
  • class (optional): CSS class for the table html element
  • caption (optional): Text string for the table caption.
  • no_header: This switch disables the generation of table header (<th>) elements. By default, the table directive uses the first data line as column headers.

The data and file parameters are mutually exclusive.

Note: the automatic format detection mechanism is still very rudimentary.

Changelog

version 0.5

  • Remove a call to an inexistent [[cpan Text::CSV]] method.
  • Added the sep_char parameter.
  • Parse CSV data in binary mode.
  • Added a format detection mechanism.
  • Default format now is 'auto'.

Links