|
csvtable_tag.wmk - define a HTML table using comma-separated values |
< use plugin="csvtable_tag" />
< csvtable [delimiter="char"] [HTML table attributes] > [...cells...] < /csvtable >
This WebMake Perl library provides a tag to allow HTML tables to be constructed, quickly, using a tab-, comma-, or pipe-separated value table.
Firstly, pick a delimiter character, such as |. Set the delimiter
attribute to this character.
Each line of the CSV table will become a < TR >; each delimiter-separated cell will be enclosed in a < TD > tag pair.
Attributes for the HTML table tag itself, can be provided as attributes to this tag; they will be passed through into the resulting < TABLE > tag.
By default, items inside the tables are represented as < TD > cells, with no attributes. Certain special line prefixes allow control over formatting of table items, as follows. These are all case-insensitive, and whitespace after them will be stripped; but they must start on the first character of the line (no leading spaces), and, despite how they're rendered here, should not contain any spaces between the angle brackets.
Blank lines are skipped.
The line should end in a < /csvfmt > closing tag.
Specify a < tr >...< /tr > block, with $1, $2, $3, etc. for the numbered cells (counting from 1). For example:
< csvfmt >< tr >< td >$1< /td >< td >$2< /td >< td >$3< /td >< /tr >< /csvfmt >
< csvtable delimiter="|" > < !-- heading -- > < csvfmt >< tr >< th >$1< /th >< th >$2< /th >< th >$3< /th >< /tr ></ csvfmt > First Name|Surname|Title < !-- contents -- > < csvfmt >< tr >< td >$1< /td >< td >$2< /td >< td >$3< /td >< /tr ></ csvfmt > Justin|Mason|JAPH Foo|Bar|Baz < /csvtable >
Thanks to Chris Barrett; he suggested this tag.
|
csvtable_tag.wmk - define a HTML table using comma-separated values |