Template::Plugin::IO::All - IO::All + Template


Template-Plugin-IO-All documentation Contained in the Template-Plugin-IO-All distribution.

Index


Code Index:

NAME

Top

Template::Plugin::IO::All - IO::All + Template

SYNOPSIS

Top

  [% USE IO.All %]
  [% file = IO.All.new('some_file') %]

  [% file.all %]

  [% FOREACH line = file.getlines %]
    [% line %]
  [% END %]

  [% file.11 %]  # Return the 11st line 

  [% dir = IO.All.new('some_dir/') %]
  [% FOREACH entry = d.all %]
   [%- entry %]
  [% END %]

DESCRIPTION

Top

Nothing much to explain. It's IO::All plugin for Template. Fun and easy!

COPYRIGHT

Top

SEE ALSO

Top

IO::All, Template::Plugin


Template-Plugin-IO-All documentation Contained in the Template-Plugin-IO-All distribution.

package Template::Plugin::IO::All;

use strict;
use base qw( Template::Plugin );

use IO::All;
#use Data::Dumper;

$Template::Plugin::IO::All::VERSION = '0.01';

sub load {
    my ($class, $context) = @_;
    bless {
            _CONTEXT => $context,
        }, $class;
}

sub new {
    my ($self, $context, @params) = @_;
    if($context and not ref $context){
	$self->{_io} = io($context);
    }
    $self;
}


sub AUTOLOAD {
    my $sub = $Template::Plugin::IO::All::AUTOLOAD;
    $sub =~ s/^Template::Plugin::IO::All:://o;
#    print "[$sub]\n";

    if($sub =~ /^([+\-]?\d+)$/){    # Access content on a certain line
	shift->{_io}->[$1];
    }
    elsif($sub ne 'DESTROY'){
	shift->{_io}->$sub(@_);
    }
}

1;

__END__