# HG changeset patch # User wizard # Date 1286284851 -14400 # Node ID 8638dd1374bf8cf6794208f118b7cf1d4918ed8d # Parent 05df123a2ff1c8b1bf5c49266869f832aa6a20e1 Added template property to IMPL::Web::QueryHandler::PageFormat (this allows to specify exact template (filename, ref to a scalar, ref to a file handle)). diff -r 05df123a2ff1 -r 8638dd1374bf Lib/IMPL/Web/QueryHandler/PageFormat.pm --- a/Lib/IMPL/Web/QueryHandler/PageFormat.pm Thu Sep 30 18:11:32 2010 +0400 +++ b/Lib/IMPL/Web/QueryHandler/PageFormat.pm Tue Oct 05 17:20:51 2010 +0400 @@ -24,6 +24,7 @@ public property cache => prop_all; public property preprocess => prop_all; public property formatOutput => prop_all; + public property template => prop_all; } sub CTOR { @@ -74,7 +75,7 @@ pop @pathContainer; $doc->LoadFile ( - File::Spec->catfile($this->templatesBase,@path), + ($this->template || File::Spec->catfile($this->templatesBase,@path)), $this->templatesCharset, $this->templatesBase, { diff -r 05df123a2ff1 -r 8638dd1374bf Lib/IMPL/Web/TT/Document.pm --- a/Lib/IMPL/Web/TT/Document.pm Thu Sep 30 18:11:32 2010 +0400 +++ b/Lib/IMPL/Web/TT/Document.pm Tue Oct 05 17:20:51 2010 +0400 @@ -12,6 +12,7 @@ use IMPL::Web::TT::Control; use Carp; use Encode(); +use Data::Dumper; BEGIN { private property _provider => prop_all; @@ -82,6 +83,12 @@ }, encode => sub { Encode::encode('utf8',shift); + }, + dump => sub { + Dumper(shift); + }, + as_list => sub { + [ map ref($_) eq 'ARRAY' ? @$_ : $_, @_ ] } }, RECURSION => 1, @@ -164,18 +171,22 @@ } sub LoadFile { - my ($this,$filePath,$encoding,$includes,$vars) = @_; + my ($this,$src,$encoding,$includes,$vars) = @_; - die new IMPL::InvalidArgumentException("A filePath parameter is required") unless $filePath; + die new IMPL::InvalidArgumentException("A template parameter is required") unless $src; + + $includes = [$includes] if $includes and not ref $includes; $encoding ||= 'utf8'; $this->_context(undef); $this->_provider(undef); - my ($vol,$dir,$fileName) = File::Spec->splitpath($filePath); - - my $inc = File::Spec->catpath($vol,$dir,''); + if (not ref $src) { + my ($vol,$dir,$fileName) = File::Spec->splitpath($src); + push @$includes, File::Spec->catpath($vol,$dir,''); + $src = $fileName; + } $this->provider( ENCODING => $encoding, @@ -185,7 +196,7 @@ TRIM => 0, COMPILE_EXT => $this->cache ? '.ttc' : undef, COMPILE_DIR => $this->cache, - INCLUDE_PATH => [$inc,ref $includes ? @$includes : $includes ] + INCLUDE_PATH => $includes ); if ($vars) { @@ -196,7 +207,7 @@ $this->context->process($_) foreach $this->preprocess; - my $template = $this->context->template($fileName); + my $template = $this->context->template($src); $this->title($template->title); if ( $template->template ) { $this->context->process($template);