diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-07-18 17:28:50 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-07-18 17:28:50 -0400 |
commit | 6c22103b732db1aa3c4602d0ab58133c537d0080 (patch) | |
tree | f1794550a091bce3174fc21e902d02b128caa9b9 /lib | |
parent | 1b404926df08ac4bbe6cbd2c7ada14de6cebda63 (diff) | |
download | spreadsheet-template-6c22103b732db1aa3c4602d0ab58133c537d0080.tar.gz spreadsheet-template-6c22103b732db1aa3c4602d0ab58133c537d0080.zip |
fix rendering two spreadsheets with the same object
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Spreadsheet/Template.pm | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/lib/Spreadsheet/Template.pm b/lib/Spreadsheet/Template.pm index e4c568a..5a2aa23 100644 --- a/lib/Spreadsheet/Template.pm +++ b/lib/Spreadsheet/Template.pm @@ -366,10 +366,9 @@ has writer_options => ( default => sub { {} }, ); -has processor => ( +has _processor => ( is => 'ro', does => 'Spreadsheet::Template::Processor', - handles => 'Spreadsheet::Template::Processor', lazy => 1, default => sub { my $self = shift; @@ -379,18 +378,12 @@ has processor => ( }, ); -has writer => ( - is => 'ro', - does => 'Spreadsheet::Template::Writer', - handles => 'Spreadsheet::Template::Writer', - lazy => 1, - default => sub { - my $self = shift; - my $class = $self->writer_class; - load_class($class); - return $class->new($self->writer_options); - }, -); +sub _writer { + my $self = shift; + my $class = $self->writer_class; + load_class($class); + return $class->new($self->writer_options); +} =method render($template, $vars) @@ -404,11 +397,11 @@ L<Spreadsheet::Template::Writer> instance. sub render { my $self = shift; my ($template, $vars) = @_; - my $contents = $self->process($template, $vars); + my $contents = $self->_processor->process($template, $vars); # not decode_json, since we expect that we are already being handed a # character string (decode_json also decodes utf8) my $data = from_json($contents); - return $self->write($data); + return $self->_writer->write($data); } __PACKAGE__->meta->make_immutable; |