Andrew Maltsev > XAO-Web-1.07 > XAO::DO::Web::TextTable

Download:
XAO-Web-1.07.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 2.001   Source  

NAME ^

XAO::DO::Web::TextTable - plain text tables

SYNOPSIS ^

 <%TextTable mode="start"
             format=" l | r | l "
 %>

 <%TextTable mode="head"
             cell.1.template="Name"
             cell.2.template="Price"
             cell.3.template="Description"
 %>

 <%TextTable mode="ruler" symbol="-"%>

 <%TextTable cell.1.template="Fubar"
             cell.2.template={<%Styler/f dollars="123.34"%>}
             cell.3.path="/bits/show-description
             cell.3.ID="123456"
 %>

 <%TextTable mode="render" width="70"%>

DESCRIPTION ^

Web::TextTable object allows to create simple pre-formatted text only tables out of various dynamic content. It currently uses David Schweikert's Text::FormatTable module internally.

Due to rendering requirements generating a table is a multi-step process:

  1. First you declare a new text table and specify its format. Arguments accepted on that step are:
     mode   => 'start'
     format => format string as descriped in L<Text::FormatTable>
  2. You fill the table by using mode equal to 'row' (default mode), 'head' or 'ruler'.

    Modes for 'row' and 'head' take the same arguments and currently display exactly the same results:

     mode            => 'head' or 'row'
     cell.X.template => inline template for cell X of the row (see below)
     cell.X.path     => path to a template
     cell.X.pass     => pass all current arguments to the template
     cell.X.VAR      => make 'VAR' available to the template with the given
                        content

    Here 'X' may be anything as long as alphanumerically ordered cell.*.* lines give exactly the required number of columns. It is recommended to use single digits in incrementing order to designate rows:

     <%TextTable mode="head"
                 cell.1.template="Fubar"
                 cell.2.path="/bits/show-price"
                 cell.2.PRICE="123.23"
                 cell.3.path="/bits/show-description
                 cell.3.ID="123456"
     %>

    For 'ruler' mode the only optional argument is 'symbol' - what symbol to use to draw the ruler. The default is '-'.

  3. Final step is to use 'render' mode to actually draw the table. One optional argument is 'width' -- the final width of the table. Default width is 75 characters.
     <%TextTable mode="render"%>

Tables can be nested as long as there is a 'render' for each 'start'.

Internally Web::TextTable uses clipboard variable located at '/var/TextTable'.

Note: You need to be careful with extra spaces and newlines. One way of dealing with it is to enclose table preparation into an unused variable brackets to just throw away extra space:

<%SetArg name="UNUSED" value={ <%TextTable ....%> <%TextTable ....%> <%TextTable ....%> }%><%TextTable mode="render"%>

AUTHOR ^

Copyright (c) 2005 Andrew Maltsev

Copyright (c) 2001-2004 Andrew Maltsev, XAO Inc.

<am@ejelta.com> -- http://ejelta.com/xao/

SEE ALSO ^

Recommended reading: XAO::Web, Text::FormatTable.

syntax highlighting: