Data::Tabulate::Plugin::HTMLTable - HTML::Table plugin for Data::Tabulate


Data-Tabulate-Plugin-HTMLTable documentation Contained in the Data-Tabulate-Plugin-HTMLTable distribution.

Index


Code Index:

NAME

Top

Data::Tabulate::Plugin::HTMLTable - HTML::Table plugin for Data::Tabulate

VERSION

Top

version 0.03

SYNOPSIS

Top

This module renders the table for HTML

    use Data::Tabulate;

    my @array = (1..10);
    my $foo   = Data::Tabulate->new();
    my $html  = $foo->render('HTMLTable',{data => [@array]});

METHODS

Top

new

create a new object of Data::Tabulate::Plugin::HTMLTable.

output

returns a string that contains the HTML source for the table

attributes

set some attributes for HTML::Table.

AUTHOR

Top

Renee Baecker <module@renee-baecker.de>

COPYRIGHT AND LICENSE

Top


Data-Tabulate-Plugin-HTMLTable documentation Contained in the Data-Tabulate-Plugin-HTMLTable distribution.

package Data::Tabulate::Plugin::HTMLTable;

use warnings;
use strict;
use HTML::Table;

# ABSTRACT: HTML::Table plugin for Data::Tabulate

our $VERSION = '0.03';


sub new{
    return bless {},shift;
}


sub output {
    my ($self,@data) = @_;
    
    my %atts = $self->attributes();
    my $obj  = HTML::Table->new(%atts);
    for(@data){
        my @row = map{defined($_) ? $_ : '&nbsp;'}@$_;
        $obj->addRow(@row);
    }
    
    return $obj->getTable();
}


sub attributes{
    my ($self,%atts) = @_;
    $self->{attributes} = {%atts} if keys %atts;
    my %return = ();
    if(defined $self->{attributes} and ref($self->{attributes}) eq 'HASH'){
        %return = %{$self->{attributes}}
    }
    return %return;
}

1; # End of Data::Tabulate::Plugin::HTMLTable

__END__