diff 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
line wrap: on
line diff
--- a/Lib/IMPL/Web/QueryHandler/PageFormat.pm	Thu Jul 01 17:32:29 2010 +0400
+++ b/Lib/IMPL/Web/QueryHandler/PageFormat.pm	Mon Jul 05 02:22:42 2010 +0400
@@ -4,6 +4,7 @@
 
 __PACKAGE__->PassThroughArgs;
 
+use JSON;
 use IMPL::Class::Property;
 use IMPL::Web::TT::Document;
 use Template::Plugin::URL;
@@ -69,17 +70,20 @@
 		pop @pathContainer;
 		
 		$doc->LoadFile ( File::Spec->catfile($this->templatesBase,@path), $this->templatesCharset, $this->templatesBase );
+		
 		$doc->AddVar( result => $nextHandler->() );
 		$doc->AddVar( app => $action->application );
+		
 		$doc->AddVar( absoluteUrl => sub { join '/', @root, $_[0] } );
 		$doc->AddVar( baseUrl => sub { join '/', @root, @base, $_[0] } );
 		$doc->AddVar( relativeUrl => sub { join '/', @root, @base, @pathContainer,$_[0] } );
-		{
-			local $@;
-			$doc->AddVar( user => IMPL::Security::Context->current->principal );
-			$doc->AddVar( session => IMPL::Security::Context->current );
-			warn $@ if $@;
-		}
+		
+		$doc->AddVar( user => IMPL::Security::Context->current->principal );
+		$doc->AddVar( session => IMPL::Security::Context->current );
+		
+		$doc->AddVar( to_json => \&to_json );
+		$doc->AddVar( escape_string => sub { $_[0] =~ s/"/"/g; $_[0] } );
+		
 		
 		$action->response->contentType('text/html');
 		my $hOut = $action->response->streamBody;