HTML::TagHelper - Generate HTML tags in an easy way
Version 0.01
use HTML::TagHelper; my $th = HTML::TagHelper->new(); print $th->image_tag(...); print $th->link_to(...); my $th->text_field_tag(...); my $th->select_tag(...); my $th->options_for_select(...);
The module contains some code generators to easily create tags for links, images, select-tags etc.
This is mostly a port of the Ruby on Rails helper tags for use in Catalyst.
Create an img html element pointing to $src.
$src
Required options are:
src: Specifies the link to the image to be displayed.
src
Addtional options are:
alt: An alt text for the tag. B default this is the filename of src without extension.
alt
escape_html: Whether or not you want to escape the outputted html (default is 1).
escape_html
Besides this options, you can enter any option you want as an attribute on the tag, e.g. class, id etc.
Create an 'a' html element with the flexibility to make popups, post to the url instead, ask for confirmation etc.
content: Specifies what the visible text is to the user (the stuff between <a> and </a>).
content
href: Where the link should point to (default is #).
href
escape_html: Whether or not you want to escape the outputted html (default is 0).
confirm: The text that will popup in a confirm box.
confirm
popup: Opens a new window where the source is href.
popup
method: If you want to use 'POST' instead of 'GET'.
method
Create a text input html element.
name: The content of the name attribute on the tag
name
id: The content of the id attribute on the tag (defaults to the value of name).
id
value: The value of the tag
value
Create a select html element.
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:
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_tag.
select_tag
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"
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>
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.