Excel-Template-Plus-0.05000755000765000765 011340511643 15163 5ustar00stevanstevan000000000000Build.PL000444000765000765 166711340511643 16547 0ustar00stevanstevan000000000000Excel-Template-Plus-0.05use Module::Build; use strict; use warnings; my $build = Module::Build->new( module_name => 'Excel::Template::Plus', license => 'perl', requires => { 'Excel::Template' => '0', 'Template' => '0', 'IO::String' => '0', 'Moose' => '0.18', 'MooseX::Param' => '0.01', # for Test::Excel::Template::Plus 'Test::Deep' => '0', 'Spreadsheet::ParseExcel' => '0', }, optional => { }, build_requires => { 'Test::More' => '0.47', 'Test::Exception' => '0.21', 'File::Spec' => '0', 'FindBin' => '0', }, create_makefile_pl => 'traditional', recursive_test_files => 1, add_to_cleanup => [ 'META.yml', '*.bak', '*.gz', 'Makefile.PL', ], ); $build->create_build_script; ChangeLog000444000765000765 226011340511643 17013 0ustar00stevanstevan000000000000Excel-Template-Plus-0.05Changes for Excel::Template::Plus 0.05 Mon. Feb 22, 2010 - updates copyright on all files * Test::Excel::Template::Plus - Fixing some test failures because of an internals change in Spreadsheet::ParseExcel - thanks to Chris Travers 0.04 Mon. Dec. 31, 2007 * Excel::Template::Plus - added example template to the docs thanks to Peter Karman for this. * Excel::Template::Plus::TT - removed the 'use FindBin' at the top which was doing nothing at all 0.03 Tues, July 3, 2007 * Excel::Template::Plus::TT - added template_class to allow for using subclasses of Template - removed File::Tempfile and File::Slurp dependency in favor of using IO::String instead 0.02 Tues, March 13, 2007 * Excel::Template::Plus - Now uses the Class::MOP::load_class method (bumped up the Moose dependency to make sure all is aligned) * Excel::Template::Plus::TT - removed param method and added the MooseX::Param role instead 0.01 Friday, March 2, 2007 - initial module release - adapted from several in-house add-ons to Excel::Template and Excel::Template::TTMakefile.PL000444000765000765 173411340511643 17220 0ustar00stevanstevan000000000000Excel-Template-Plus-0.05# Note: this file was auto-generated by Module::Build::Compat version 0.35 use ExtUtils::MakeMaker; WriteMakefile ( 'NAME' => 'Excel::Template::Plus', 'VERSION_FROM' => 'lib/Excel/Template/Plus.pm', 'PREREQ_PM' => { 'Excel::Template' => '0', 'File::Spec' => '0', 'FindBin' => '0', 'IO::String' => '0', 'Moose' => '0.18', 'MooseX::Param' => '0.01', 'Spreadsheet::ParseExcel' => '0', 'Template' => '0', 'Test::Deep' => '0', 'Test::Exception' => '0.21', 'Test::More' => '0.47' }, 'INSTALLDIRS' => 'site', 'EXE_FILES' => [], 'PL_FILES' => {}, 'TESTS' => 't/*.t t/templates/*.t t/xls/*.t' ) ; MANIFEST000444000765000765 37611340511643 16360 0ustar00stevanstevan000000000000Excel-Template-Plus-0.05Build.PL ChangeLog Makefile.PL META.yml MANIFEST MANIFEST.SKIP README lib/Excel/Template/Plus.pm lib/Excel/Template/Plus/TT.pm lib/Test/Excel/Template/Plus.pm t/000_load.t t/001_basic.t t/pod.t t/pod_coverage.t t/templates/basic.tmpl t/xls/001_basic.xls MANIFEST.SKIP000444000765000765 24411340511643 17117 0ustar00stevanstevan000000000000Excel-Template-Plus-0.05^_build ^Build$ ^blib ~$ \.bak$ ^MANIFEST\.SKIP$ CVS \.svn \.DS_Store cover_db \..*\.sw.?$ ^Makefile$ ^pm_to_blib$ ^MakeMaker-\d ^blibdirs$ \.old$ ^#.*#$ ^\.# ^miscMETA.yml000444000765000765 157711340511643 16524 0ustar00stevanstevan000000000000Excel-Template-Plus-0.05--- name: Excel-Template-Plus version: 0.05 author: - 'Stevan Little Estevan@iinteractive.comE' abstract: An extension to the Excel::Template module license: perl resources: license: http://dev.perl.org/licenses/ build_requires: File::Spec: 0 FindBin: 0 Test::Exception: 0.21 Test::More: 0.47 requires: Excel::Template: 0 IO::String: 0 Moose: 0.18 MooseX::Param: 0.01 Spreadsheet::ParseExcel: 0 Template: 0 Test::Deep: 0 configure_requires: Module::Build: 0.35 provides: Excel::Template::Plus: file: lib/Excel/Template/Plus.pm version: 0.05 Excel::Template::Plus::TT: file: lib/Excel/Template/Plus/TT.pm version: 0.05 Test::Excel::Template::Plus: file: lib/Test/Excel/Template/Plus.pm version: 0.02 generated_by: Module::Build version 0.35 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 README000444000765000765 147411340511643 16127 0ustar00stevanstevan000000000000Excel-Template-Plus-0.05Excel::Template::Plus version 0.04 ===================================== See the individual module documentation for more information INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: Excel::Template Template IO::String Moose MooseX::Param The Test::Excel::Template::Plus module also requires: Test::Deep Spreadsheet::ParseExcel And requires these modules for testing: Test::More Test::Exception FindBin File::Spec::Functions COPYRIGHT AND LICENCE Copyright (C) 2007-2010 Infinity Interactive, Inc. http://www.iinteractive.com This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. lib000755000765000765 011340511643 15652 5ustar00stevanstevan000000000000Excel-Template-Plus-0.05Excel000755000765000765 011340511643 16712 5ustar00stevanstevan000000000000Excel-Template-Plus-0.05/libTemplate000755000765000765 011340511643 20465 5ustar00stevanstevan000000000000Excel-Template-Plus-0.05/lib/ExcelPlus.pm000444000765000765 1067311340511643 22132 0ustar00stevanstevan000000000000Excel-Template-Plus-0.05/lib/Excel/Template package Excel::Template::Plus; use Moose; our $VERSION = '0.05'; our $AUTHORITY = 'cpan:STEVAN'; sub new { shift; my %options = @_; my $engine_class = 'Excel::Template::Plus::' . $options{engine}; eval { Class::MOP::load_class($engine_class) }; if ($@) { confess "Could not load engine class ($engine_class) because " . $@; } my $template = eval { $engine_class->new(%options) }; if ($@) { confess "Could not create template from engine class ($engine_class) because " . $@; } return $template; } no Moose; 1; __END__ =pod =head1 NAME Excel::Template::Plus - An extension to the Excel::Template module =head1 SYNOPSIS use Excel::Template::Plus; my $template = Excel::Template::Plus->new( engine => 'TT', template => 'greeting.tmpl', config => { INCLUDE => [ '/templates' ] }, params => { greeting => 'Hello' } ); $template->param(location => 'World'); $template->write_file('greeting.xls'); =head1 DISCLAIMER This is the very first release of this module, it is an idea that I and Rob Kinyon (the author of Excel::Template) had discussed many times, but never got around to doing. This is the first attempt at bring this to reality, it may change B as it evolves, so be warned. =head1 DESCRIPTION This module is an extension of the Excel::Template module, which allows the user to use various "engines" from which you can create Excel files through Excel::Template. The idea is to use the existing (and very solid) excel file generation code in Excel::Template, but to extend its more templatey bits with more powerful options. The only engine currently provided is the Template Toolkit engine, which replaces Excel::Template's built in template features (the LOOP, and IF constructs) with the full power of TT. This is similar to the module Excel::Template::TT, but expands on that even further to try and create a more extensive system. You can use this module to create Excel::Template-compatible XML files using one of the supported engines. For example, with the TT engine you could create a Excel::Template XML file like: [% my_cols = get_list_of_columns %] [% FOR col = my_cols %] [% col %] [% END %] [% FOR my_row = get_list_of_objects %] [% FOR col = my_cols %] [% my_row.$col %] [% END %] [% END %] Your TT template thus creates a XML file suitable to handing over to Excel::Template for processing. Excel::Template::Plus simplifies the template-creation and handing-over process. Future engine/plans include: =over 4 =item Pure Perl This would allow you to write you Excel::Template files using Perl itself which would then output the XML for Excel::Template to consume. This would be modeled after the recently released L module perhaps. =item TT Plugins/Macros/Wrappers This is basically anything which will make the TT engine easier to write templates for. I have experimented with some of these things, but I was not happy with any of them enough to release them yet. =item HTML::Template Excel::Template's templating features are based on HTML::Template, but the HTML::Template plugins and other goodies are not compatible. This engine would bring those things to Excel::Template. =back =head1 METHODS =over 4 =item B This method basically serves as a factory for creating new engine instances (for which L is the only one currently). The only parameter that it requires is I, all other parameters are passed onto the engine's constructor (see the individual docs for more details on what is required). =item B Access to the metaclass. =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 ACKNOWLEDGEMENTS =over 4 =item This module came out of several discussions I had with Rob Kinyon. =back =head1 AUTHOR Stevan Little Estevan@iinteractive.comE =head1 COPYRIGHT AND LICENSE Copyright 2007-2010 by Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Plus000755000765000765 011340511643 21410 5ustar00stevanstevan000000000000Excel-Template-Plus-0.05/lib/Excel/TemplateTT.pm000444000765000765 763611340511643 22446 0ustar00stevanstevan000000000000Excel-Template-Plus-0.05/lib/Excel/Template/Plus package Excel::Template::Plus::TT; use Moose; use Moose::Util::TypeConstraints; use Template (); use IO::String (); use Excel::Template; our $VERSION = '0.05'; our $AUTHORITY = 'cpan:STEVAN'; with 'MooseX::Param'; subtype 'IO::Handle' => as 'Object' => where { $_->isa('IO::Handle') }; has 'template' => ( is => 'ro', # can either be a: # - filename # - scalar ref to string # - open filehandle # - an IO::Handle instance # (basically anything TT takes) isa => 'Str | ScalarRef | FileHandle | IO::Handle', required => 1, ); has 'config' => ( is => 'ro', isa => 'HashRef', default => sub {{}}, ); has '_template_object' => ( is => "rw", isa => "Template", lazy => 1, default => sub { my $self = shift; my $class = $self->template_class; Class::MOP::load_class($class); ($class->isa('Template')) || confess "The template_class must be Template or a subclass of it"; $class->new( $self->config ) } ); has 'template_class' => ( is => "rw", isa => "Str", default => "Template", ); ## private attributes has '_excel_template' => ( is => 'ro', isa => 'Excel::Template', handles => [qw[ output write_file ]], lazy => 1, default => sub { my $self = shift; $self->_prepare_excel_template; } ); sub _prepare_excel_template { my $self = shift; my $buf; my $fh = IO::String->new(\$buf); my $tt = $self->_template_object; $tt->process( $self->template, $self->params, $fh, ); $fh->pos(0); confess "Template creation failed because : " . $tt->error() if $tt->error(); confess "Template failed to produce any output" unless length($buf); my $excel_template = eval { Excel::Template->new(file => $fh) }; if ($@) { warn $buf; confess $@; } return $excel_template; } no Moose; no Moose::Util::TypeConstraints; 1; __END__ =pod =head1 NAME Excel::Template::Plus::TT - Extension of Excel::Template to use TT =head1 SYNOPSIS use Excel::Template::Plus::TT; # this is most commonly used through # the Excel::Template::Plus factory my $template = Excel::Template::Plus::TT->new( template => 'greeting.tmpl', config => { INCLUDE => [ '/templates' ] }, params => { greeting => 'Hello' } ); $template->param(location => 'World'); $template->write_file('greeting.xls'); =head1 DESCRIPTION This is an engine for Excel::Template::Plus which replaces the standard Excel::Template template features with TT. See the L docs for more information. =head1 METHODS =head2 Accessors =over 4 =item B =item B