The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::TagHelper - Generate HTML tags in an easy way

VERSION

Version 0.02

SYNOPSIS

    use HTML::TagHelper;

    my $th = HTML::TagHelper->new();
    $th->t( 'bar', class => 'test', 0);
    $th->link_to('http://example.com/', title => 'Foo', sub { 'Foo' });
    $th->js('amcharts/ammap');
    $th->css('amcharts/style');
    $th->form_for('/links', sub {
      $th->text_field(foo => 'bar')
        . $th->input_tag(baz => 'yada', class => 'tset')
        . $th->submit_button
    });
    $th->date_select_field('date', {
        year_start => 2013,
        year_end => 2013
    });
    $th->options_for_select(
      [ {title => "Option 1", value => "option1"},
        {title => "Option 2", value => "option2"}, ],
      [ 'option1' ],
    );
    $th->textarea(e => (cols => 40, rows => 50) => sub {'text in textarea'});
    $th->image('/uploads/001.jpg');

DESCRIPTION

The module contains some code generators to easily create tags for links, images, select-field etc.

This is mostly a port of the Ruby on Rails helper tags for use in Catalyst. And alias tags name as Mojolicious::Plugin::TagHelpers.

FUNCTIONS

color_field

email_field

number_field

range_field

search_field

tel_field

text_field

url_field

tag/t

check_box

file_field

image

input_tag

password_field

radio_button

form_for

hidden_field

js

css

submit_button

textarea

select_field

$th->select_field($name, \@options, \%html_options)

Create a select html element.

Required options are:

name: The content of the name attribute on the tag

The options array must contain either the output of options_for_select or an array of hashes with title and value as keys.

Addtional html_options are:

id: The content of the id attribute on the tag (defaults to the value of name).

Besides this html_option, you can enter any option you want as an attribute on the tag, e.g. class, id etc.

options_for_select

$th->options_for_select(\@options)

Create all options html elements to put inside select_field.

Required options are:

options: This is an array of hashes, where the title pair will be used for content of the tag, and the value pair will be used for value.

Example:

    $th->options_for_select( [{title => "Option 1", value="option1"}, {title => "Option 2", value => "option2"}] );

date_select_field

$th->date_select_field($name, \%options)

Create 3 select html element - one for day, one for month and one for year.

Required options are:

name: The content of the name attribute on the tag. They are all post-fixed with "day", "month" or "year"

The options array must contain either the output of options_for_select or an array of hashes with title and value as keys.

Addtional options are:

year_start: Which year should be the first option. Defaults to DateTime->now->year

year_end: Which your should be the last option. Default to start_year + 5

id: The content of the id attribute on the tag (defaults to the value of name).

class: The content of the class attributes on the tags.

Besides this html_option, you can enter any option you want as an attribute on the tag, e.g. class, id etc.

AUTHOR

Gitte Wange Olrik, <gitte at olrik.dk>

Chenryn, <chenlin.rao at gmail.com>

BUGS

Please report any bugs or feature requests to bug-html-taghelper at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-TagHelper. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc HTML::TagHelper

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2008 Gitte Wange Olrik, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.