diff Lib/IMPL/Web/QueryHandler/PageFormat.pm @ 146:60fd224f3e3c

fixed cgi parameters processing Added parameters inflating feature Added preprocessed templates, reformatting output
author wizard
date Mon, 26 Jul 2010 03:19:06 +0400
parents b56ebc31bf18
children eb478083f72b
line wrap: on
line diff
--- a/Lib/IMPL/Web/QueryHandler/PageFormat.pm	Wed Jul 21 06:27:12 2010 +0400
+++ b/Lib/IMPL/Web/QueryHandler/PageFormat.pm	Mon Jul 26 03:19:06 2010 +0400
@@ -10,6 +10,7 @@
 use Template::Plugin::URL;
 use IMPL::Security::Context;
 use File::Spec;
+use HTML::TreeBuilder;
 use Error qw(:try);
 
 $Template::Plugin::URL::JOINT = '&';
@@ -20,6 +21,8 @@
 	public property defaultTarget => prop_all;
 	public property pathinfoPrefix => prop_all;
 	public property cache => prop_all;
+	public property preprocess => prop_all;
+	public property formatOutput => prop_all;
 }
 
 sub CTOR {
@@ -33,7 +36,7 @@
 sub Process {
 	my ($this,$action,$nextHandler) = @_;
 	
-	my $doc = new IMPL::Web::TT::Document(cache => $this->cache);
+	my $doc = new IMPL::Web::TT::Document(cache => $this->cache, preprocess => $this->preprocess);
 	
 	try {
 
@@ -88,7 +91,20 @@
 		
 		$action->response->contentType('text/html');
 		my $hOut = $action->response->streamBody;
-		print $hOut $doc->Render();
+		if ($this->formatOutput == 1) {
+			my $tree = new HTML::TreeBuilder();
+			try {
+				$tree->parse_content($doc->Render());
+				print $hOut $tree->as_HTML('<>&',"    ",{});
+			} finally {
+				$tree->delete;
+			};
+		} elsif ($this->formatOutput() == 2 ) {
+			(my $data = $doc->Render()) =~ s/\s+/ /g;
+			print $hOut $data;
+		} else {
+			print $hOut $doc->Render();
+		}
 	} finally {
 		$doc->Dispose;
 	};