++ed by:

1 non-PAUSE user.

Tina Müller
and 1 contributors

NAME

HTML::Template::Compiled::Plugin::HTML_Tags - HTC-Plugin for various HTML tags

SYNOPSIS

    use HTML::Template::Compiled::Plugin::HTML_Tags;

    my $htc = HTML::Template::Compiled->new(
        plugin => [qw(HTML::Template::Compiled::Plugin::HTML_Tags)],
        ...
    );

DESCRIPTION

This plugin offers you five tags:

HTML_OPTION
    <tmpl_html_option arrayref>

    $htc->param(
        arrayref => [ 'opt_2', # selected
            ['opt_1', 'option 1'],
            ['opt_2', 'option 2'],
        ],
    );

    Output:
    <option value="opt_1">option 1</option>
    <option value="opt_2" selected="selected">option 2</option>

You can also select multiple options:

    $htc->param(
        arrayref => [ ['opt_1','opt_2'], # selected
            ['opt_1', 'option 1'],
            ['opt_2', 'option 2'],
        ],
    );

If you have values and labels equal (for example in a year-select), you can use this syntax:

    $htc->param(
        arrayref => [ 2007, # selected
            '2005',
            '2006',
            '2007',
        ],
    );

    Output:
    <option value="2005">2005</option>
    <option value="2006">2006</option>
    <option value="2007" selected="selected">2007</option>
HTML_SELECT
    <tmpl_html_select select SELECT_ATTR="class='myselect'">

    $htc->param(
        select => {
            name => 'foo',
            value => 'opt_1',
            options => [
                ['opt_1', 'option 1'], # or use simple scalars if values and labals are equal
                ['opt_2', 'option 2'],
            ],
        },
    );

    Output:
    <select name='foo' class='myselect'>
    <option value="opt_1" selected="selected">option 1</option>
    <option value="opt_2">option 2</option>
    </select>
HTML_OPTION_LOOP

I'm using tt-style syntax here (see option tagstyle in HTML::Template::Compiled) for readability:

    <select name="foo">
    [%html_option_loop arrayref%]
    <option value="[%= value%]" [%= selected%] >[%= label %]</option>
    [%/html_option_loop%]
    </select>

    $htc->param(
        arrayref => [ 'opt_2',
            ['opt_1', 'option 1'], # or use simple scalars if values and labals are equal
            ['opt_2', 'option 2'],
        ],
    );

    Output:
    <select name="foo">
    <option value="opt_1" >option 1</option>
    <option value="opt_2" selected="selected">option 2</option>
    </select>
HTML_BOX_LOOP

I'm using tt-style syntax here for readability:

    [%html_box_loop arrayref%]
    <checkbox name="foo" value="[%= value%]" [%= selected%] >[%= label %]
    [%/html_box_loop%]

    $htc->param(
        arrayref => [ 'opt_2',
            ['opt_1', 'option 1'], # or use simple scalars if values and labals are equal
            ['opt_2', 'option 2'],
        ],
    );

    Output:
    <checkbox name="foo" value="opt_1" >option 1
    <checkbox name="foo" value="opt_2" checked="checked">option 2

This can also be used with radio boxes. Code is the same.

HTML_TABLE
    Easy example:
    <tmpl_html_table arrayref>

    Example with all possible attributes:
    <tmpl_html_table arrayref
    header=1
    table_attr="bgcolor='black'"
    tr_attr="bgcolor='red'"
    th_attr="bgcolor='green'"
    td_attr="bgcolor='green'" >

    $htc->param(
        arrayref => [
            [qw(foo bar)], # table header
            [qw(foo bar)],
            [qw(foo bar)],
        ],
    );

    Output:
    <table bgcolor='black'>
    <tr bgcolor='red'>
    <th bgcolor='green'>foo</th><th bgcolor='green'>bar</th>
    </tr>
    <tr bgcolor='red'>
    <td bgcolor='green'>foo</td><td bgcolor='green'>bar</td>
    </tr>
    ...
    </table>

EXAMPLES

See the examples directory in this distribution.

METHODS

register

gets called by HTC

AUTHOR

Tina Mueller

COPYRIGHT AND LICENSE

Copyright (C) 2006 by Tina Mueller

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.