comparison Lib/IMPL/Web/QueryHandler/PageFormat.pm @ 140:fb896377389f

to_json and escape_string functions for the templates minor changes
author wizard
date Mon, 05 Jul 2010 02:22:42 +0400
parents 6975cd4973d1
children b56ebc31bf18
comparison
equal deleted inserted replaced
139:5a9f64890c31 140:fb896377389f
2 use base qw(IMPL::Web::QueryHandler IMPL::Object::Autofill); 2 use base qw(IMPL::Web::QueryHandler IMPL::Object::Autofill);
3 use strict; 3 use strict;
4 4
5 __PACKAGE__->PassThroughArgs; 5 __PACKAGE__->PassThroughArgs;
6 6
7 use JSON;
7 use IMPL::Class::Property; 8 use IMPL::Class::Property;
8 use IMPL::Web::TT::Document; 9 use IMPL::Web::TT::Document;
9 use Template::Plugin::URL; 10 use Template::Plugin::URL;
10 use IMPL::Security::Context; 11 use IMPL::Security::Context;
11 use File::Spec; 12 use File::Spec;
67 68
68 my @pathContainer = @path; 69 my @pathContainer = @path;
69 pop @pathContainer; 70 pop @pathContainer;
70 71
71 $doc->LoadFile ( File::Spec->catfile($this->templatesBase,@path), $this->templatesCharset, $this->templatesBase ); 72 $doc->LoadFile ( File::Spec->catfile($this->templatesBase,@path), $this->templatesCharset, $this->templatesBase );
73
72 $doc->AddVar( result => $nextHandler->() ); 74 $doc->AddVar( result => $nextHandler->() );
73 $doc->AddVar( app => $action->application ); 75 $doc->AddVar( app => $action->application );
76
74 $doc->AddVar( absoluteUrl => sub { join '/', @root, $_[0] } ); 77 $doc->AddVar( absoluteUrl => sub { join '/', @root, $_[0] } );
75 $doc->AddVar( baseUrl => sub { join '/', @root, @base, $_[0] } ); 78 $doc->AddVar( baseUrl => sub { join '/', @root, @base, $_[0] } );
76 $doc->AddVar( relativeUrl => sub { join '/', @root, @base, @pathContainer,$_[0] } ); 79 $doc->AddVar( relativeUrl => sub { join '/', @root, @base, @pathContainer,$_[0] } );
77 { 80
78 local $@; 81 $doc->AddVar( user => IMPL::Security::Context->current->principal );
79 $doc->AddVar( user => IMPL::Security::Context->current->principal ); 82 $doc->AddVar( session => IMPL::Security::Context->current );
80 $doc->AddVar( session => IMPL::Security::Context->current ); 83
81 warn $@ if $@; 84 $doc->AddVar( to_json => \&to_json );
82 } 85 $doc->AddVar( escape_string => sub { $_[0] =~ s/"/"/g; $_[0] } );
86
83 87
84 $action->response->contentType('text/html'); 88 $action->response->contentType('text/html');
85 my $hOut = $action->response->streamBody; 89 my $hOut = $action->response->streamBody;
86 print $hOut $doc->Render(); 90 print $hOut $doc->Render();
87 } finally { 91 } finally {