Perrin Harkins writes:
> That's exactly what I'm saying, except that I don't see what your 
> "layout manager" is for.  You should just pass some data to a template 
> (or maybe to something fancier for certain types of output like Excel) 
> and then the template makes all the decisions about how to show that data.

The layout manager is an important tool, which doesn't fit in with the
template model.  It comes from widget-based GUI toolkits like Java,
Tk, etc.

Layout managers accept a declaration ('this cell is northwest', 'this
other one expands across the bottom', etc.).  They interpret the decl
at run-time.  It's like HTML, but more declarative.  Some attributes
of our Grid manager are:

  cell_nowrap - don't wrap the text in the cell
  cell_align - gens valign and align from a single compass direction
  cell_expand - this cell eats up the rest of the columns in the row
  row_control - a conditional value to control whether row is displayed
  cell_width - contains the HTML width= value (may be dynamic)

With Java's GridBag and other layout managers, you relate the cells in
some way and the layout manager "does the right thing".  Since this
particular layout manager is HTML, we relate the cells in a row-major
matrix.  Since it's Perl, it's compact.  Here's a simple example:

    Grid({
        string_font => 'page_text',
        pad => 5,
        values => [
            [
                String(Join([
                    'Please confirm that the following data is correct '
                    .'and press the <b>Continue</b> button to ship the '
                    .'order',
                ])),
            ], [
                String('Billing Address', 'page_heading'),
            ], [
                &$address_widget('bill_to', 1),
            ], [
                String('Shipping Address', 'page_heading'),
            ], [
                &$address_widget('ship_to', 2),
            ], [
                ImageFormButton({
                    image => 'continue',
                    field => 'ok_button',
                    alt => 'Continue',
                }),
            ],
        ],
    }),

Rob


Reply via email to