| Template-Plugin-IO-All documentation | Contained in the Template-Plugin-IO-All distribution. |
Template::Plugin::IO::All - IO::All + Template
[% 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 %]
Nothing much to explain. It's IO::All plugin for Template. Fun and easy!
Yung-chung Lin (a.k.a. xern) <xern@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself
| 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__