HTML::TagHelper - Generate HTML tags in an easy way
Version 0.02
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');
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.
Create a select html element.
Required options are:
name: The content of the name attribute on the tag
name
The options array must contain either the output of options_for_select or an array of hashes with title and value as keys.
options_for_select
Addtional html_options are:
id: The content of the id attribute on the tag (defaults to the value of name).
id
Besides this html_option, you can enter any option you want as an attribute on the tag, e.g. class, id etc.
Create all options html elements to put inside select_field.
select_field
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.
options
Example:
$th->options_for_select( [{title => "Option 1", value="option1"}, {title => "Option 2", value => "option2"}] );
Create 3 select html element - one for day, one for month and one for year.
name: The content of the name attribute on the tag. They are all post-fixed with "day", "month" or "year"
Addtional options are:
year_start: Which year should be the first option. Defaults to DateTime->now->year
year_start
year_end: Which your should be the last option. Default to start_year + 5
year_end
start_year
class: The content of the class attributes on the tags.
class
Gitte Wange Olrik, <gitte at olrik.dk>
<gitte at olrik.dk>
Chenryn, <chenlin.rao at gmail.com>
<chenlin.rao at gmail.com>
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.
bug-html-taghelper at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc HTML::TagHelper
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTML-TagHelper
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/HTML-TagHelper
CPAN Ratings
http://cpanratings.perl.org/d/HTML-TagHelper
Search CPAN
http://search.cpan.org/dist/HTML-TagHelper
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.
To install HTML::TagHelper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::TagHelper
CPAN shell
perl -MCPAN -e shell install HTML::TagHelper
For more information on module installation, please visit the detailed CPAN module installation guide.