Mercurial > pub > Impl
diff Lib/Engine/Output/Template.pm @ 49:16ada169ca75
migrating to the Eclipse IDE
author | wizard@linux-odin.local |
---|---|
date | Fri, 26 Feb 2010 10:49:21 +0300 |
parents | 03e58a454b20 |
children |
line wrap: on
line diff
--- a/Lib/Engine/Output/Template.pm Fri Feb 26 01:43:42 2010 +0300 +++ b/Lib/Engine/Output/Template.pm Fri Feb 26 10:49:21 2010 +0300 @@ -1,55 +1,55 @@ -package Engine; -our $Encoding; - -package Engine::Output::Template; -use strict; -use Common; -use Template; -our @ISA = qw(Object); -our %Formats; - -BEGIN { - DeclareProperty Include => ACCESS_READ; - DeclareProperty ContentType => ACCESS_READ; - DeclareProperty Encoding => ACCESS_READ; -} - -sub CTOR { - my ($this,%args) = @_; - - $this->{$Include} = $args{Include} or die new Exception('An include diretory is required',$args{Format}); - $this->{$ContentType} = $args{ContentType} or die new Exception('A content type must be specied',$args{Format}); - $this->{$Encoding} = $args{Encoding}; -} - -sub Print { - my ($this,$Query,$Action) = @_; - - my $template = new Template( - { - INCLUDE_PATH => $this->{$Include}, - INTERPOLATE => 1, - RECURSION => 1, - ENCODING => $this->{$Encoding} - } - ); - - my @path = $Action->RequestURI->path_segments; - shift @path; - my $Template; - eval { - $Template = $template->context->template(join('/',@path)); - }; - print $Query->header(-type => 'text/html') and die new Exception('Failed to process a template', $@) if $@; - $Query->Expires($Template->Expires); - print $Query->header(-type => $this->{$ContentType}); - print $template->context->process($Template,{Encoding => $Engine::Encoding, Data => $Action->Result, Query => $Query }); -} - -sub construct { - my ($class,$format) = @_; - - $class->new(%{$Formats{$format}},Format => $format); -} - -1; \ No newline at end of file +package Engine; +our $Encoding; + +package Engine::Output::Template; +use strict; +use Common; +use Template; +our @ISA = qw(Object); +our %Formats; + +BEGIN { + DeclareProperty Include => ACCESS_READ; + DeclareProperty ContentType => ACCESS_READ; + DeclareProperty Encoding => ACCESS_READ; +} + +sub CTOR { + my ($this,%args) = @_; + + $this->{$Include} = $args{Include} or die new Exception('An include diretory is required',$args{Format}); + $this->{$ContentType} = $args{ContentType} or die new Exception('A content type must be specied',$args{Format}); + $this->{$Encoding} = $args{Encoding}; +} + +sub Print { + my ($this,$Query,$Action) = @_; + + my $template = new Template( + { + INCLUDE_PATH => $this->{$Include}, + INTERPOLATE => 1, + RECURSION => 1, + ENCODING => $this->{$Encoding} + } + ); + + my @path = $Action->RequestURI->path_segments; + shift @path; + my $Template; + eval { + $Template = $template->context->template(join('/',@path)); + }; + print $Query->header(-type => 'text/html') and die new Exception('Failed to process a template', $@) if $@; + $Query->Expires($Template->Expires); + print $Query->header(-type => $this->{$ContentType}); + print $template->context->process($Template,{Encoding => $Engine::Encoding, Data => $Action->Result, Query => $Query }); +} + +sub construct { + my ($class,$format) = @_; + + $class->new(%{$Formats{$format}},Format => $format); +} + +1;