Tags::HTML::Table::View - Tags helper for table view.
use Tags::HTML::Table::View; my $obj = Tags::HTML::Table::View->new(%params); $obj->cleanup; $obj->init($data_ar, $no_data_value); $obj->process; $obj->process_css;
new
my $obj = Tags::HTML::Table::View->new(%params);
Constructor.
Returns instance of object.
css
'CSS::Struct::Output' object for "process_css" processing.
Default value is undef.
css_table
CSS class for table.
Default value is 'table'.
header
Boolean flag, that means that header is in first line.
Default value is 1.
tags
'Tags::Output' object for "process" processing.
cleanup
$obj->cleanup;
Process cleanup after page run.
Returns undef.
init
$obj->init($data_ar, $no_data_value);
Process initialization before page run.
Variable $data_ar are data for table. Each item in array could be:
$data_ar
Scalar
Add scalar variable to field.
Array with scalars
Add scalar variables to field.
Code
Run this code with argument $self of this module.
$self
Data::HTML::Element::A instance
Serialize link to field.
Variable $no_data_value contain information for situation when data in table not exists.
$no_data_value
process
$obj->process;
Process Tags structure for table view.
process_css
$obj->process_css;
Process CSS::Struct structure for output.
new(): From Class::Utils::set_params(): Unknown parameter '%s'. From Tags::HTML::new(): Parameter 'css' must be a 'CSS::Struct::Output::*' class. Parameter 'tags' must be a 'Tags::Output::*' class. process(): From Tags::HTML::process(): Parameter 'tags' isn't defined. Bad value object. process_css(): From Tags::HTML::process_css(): Parameter 'css' isn't defined.
use strict; use warnings; use CSS::Struct::Output::Indent; use Tags::HTML::Table::View; use Tags::Output::Indent; # Object. my $css = CSS::Struct::Output::Indent->new; my $tags = Tags::Output::Indent->new; my $obj = Tags::HTML::Table::View->new( 'css' => $css, 'tags' => $tags, ); # Table data. my $table_data_ar = [ ['Country', 'Capital'], ['Czech Republic', 'Prague'], ['Russia', 'Moscow'], ]; # Process login button. $obj->init($table_data_ar, 'No data.'); $obj->process_css; $tags->put(['b', 'body']); $obj->process; $tags->put(['e', 'body']); $obj->cleanup; # Print out. print "CSS\n"; print $css->flush."\n\n"; print "HTML\n"; print $tags->flush."\n"; # Output: # CSS # .table, .table td, .table th { # border: 1px solid #ddd; # text-align: left; # } # .table { # border-collapse: collapse; # width: 100%; # } # .table th, .table td { # padding: 15px; # } # # HTML # <body> # <table class="table"> # <tr> # <th> # Country # </th> # <th> # Capital # </th> # </tr> # <tr> # <td> # Czech Republic # </td> # <td> # Prague # </td> # </tr> # <tr> # <td> # Russia # </td> # <td> # Moscow # </td> # </tr> # </table> # </body>
use strict; use warnings; use CSS::Struct::Output::Indent; use Tags::HTML::Table::View; use Tags::Output::Indent; # Object. my $css = CSS::Struct::Output::Indent->new; my $tags = Tags::Output::Indent->new; my $obj = Tags::HTML::Table::View->new( 'css' => $css, 'tags' => $tags, ); # Table data. my $table_data_ar = [ ['Country', 'Capital'], ]; # Process login button. $obj->init($table_data_ar, 'No data.'); $obj->process_css; $tags->put(['b', 'body']); $obj->process; $tags->put(['e', 'body']); $obj->cleanup; # Print out. print "CSS\n"; print $css->flush."\n\n"; print "HTML\n"; print $tags->flush."\n"; # Output: # CSS # .table, .table td, .table th { # border: 1px solid #ddd; # text-align: left; # } # .table { # border-collapse: collapse; # width: 100%; # } # .table th, .table td { # padding: 15px; # } # # HTML # <body> # <table class="table"> # <tr> # <th> # Country # </th> # <th> # Capital # </th> # </tr> # <tr> # <td colspan="2"> # No data. # </td> # </tr> # </table> # </body>
use strict; use warnings; use CSS::Struct::Output::Indent; use Data::HTML::Element::A; use Tags::HTML::Table::View; use Tags::Output::Indent; # Object. my $css = CSS::Struct::Output::Indent->new; my $tags = Tags::Output::Indent->new; my $obj = Tags::HTML::Table::View->new( 'css' => $css, 'tags' => $tags, ); # Table data. my $prague = Data::HTML::Element::A->new( 'data' => ['Prague'], 'url' => 'https://prague.cz', ); my $table_data_ar = [ ['Country', 'Capital'], ['Czech Republic', $prague], ['Russia', 'Moscow'], ]; # Process login button. $obj->init($table_data_ar, 'No data.'); $obj->process_css; $tags->put(['b', 'body']); $obj->process; $tags->put(['e', 'body']); $obj->cleanup; # Print out. print "CSS\n"; print $css->flush."\n\n"; print "HTML\n"; print $tags->flush."\n"; # Output: # CSS # .table, .table td, .table th { # border: 1px solid #ddd; # text-align: left; # } # .table { # border-collapse: collapse; # width: 100%; # } # .table th, .table td { # padding: 15px; # } # # HTML # <body> # <table class="table"> # <tr> # <th> # Country # </th> # <th> # Capital # </th> # </tr> # <tr> # <td> # Czech Republic # </td> # <td> # <a href="https://prague.cz"> # Prague # </a> # </td> # </tr> # <tr> # <td> # Russia # </td> # <td> # Moscow # </td> # </tr> # </table> # </body>
Class::Utils, Error::Pure, List::MoreUtils, Scalar::Util, Tags::HTML.
https://github.com/michal-josef-spacek/Tags-HTML-Table-View
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© 2021-2024 Michal Josef Špaček
BSD 2-Clause License
0.06
To install Tags::HTML::Table::View, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tags::HTML::Table::View
CPAN shell
perl -MCPAN -e shell install Tags::HTML::Table::View
For more information on module installation, please visit the detailed CPAN module installation guide.