diff Lib/IMPL/Web/TT/Document.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 bd10093bb122
children 4369d5458bb6
line wrap: on
line diff
--- a/Lib/IMPL/Web/TT/Document.pm	Wed Jul 21 06:27:12 2010 +0400
+++ b/Lib/IMPL/Web/TT/Document.pm	Mon Jul 26 03:19:06 2010 +0400
@@ -18,6 +18,7 @@
     public property cache => prop_all;
     public property template => prop_get | owner_set;
     public property presenter => prop_all, { validate => \&_validatePresenter };
+    public property preprocess => prop_all | prop_list,
     private property _controlClassMap => prop_all;
 }
 
@@ -33,6 +34,7 @@
 	$this->appendChild( $this->Create(body => 'IMPL::Web::TT::Collection') );
 	$this->appendChild( $this->Create(head => 'IMPL::Web::TT::Collection') );
 	$this->cache($args{cache}) if $args{cache};
+	$this->preprocess($args{preprocess}) if $args{preprocess};
 }
 
 sub CreateControl {
@@ -77,8 +79,6 @@
                     	$this->_process(@_);
                     }
                 },
-                POST_CHOMP => 2,
-                PRE_CHOMP => 2,
                 RECURSION => 1,
                 LOAD_TEMPLATES => [$this->provider]
             )
@@ -103,6 +103,9 @@
 	
 	die new IMPL::InvalidArgumentException("A type must be subclass of IMPL::DOM::Node",$type) unless $type->isa('IMPL::DOM::Node');
 	
+	# resolve template name to a real template
+	$args->{template} = $this->context->template($args->{template}) if $args->{template};
+	
 	$this->_controlClassMap->{$controlClass} = {
 		controlClass => $controlClass,
 		type => $type,
@@ -127,7 +130,7 @@
 	if (not $this->isControlClass($controlClass)) {
 		if ($doc->template) {
 			$controlTemplate = $doc->blocks()->{$doc->template} || $this->context->template($doc->template);
-			$out = $this->context->process($doc);
+			$out = $this->context->include($doc);
 		} else {
 			$controlTemplate = $doc;
 		}
@@ -174,11 +177,14 @@
         INTERPOLATE => 1,
         PRE_CHOMP => 1,
         POST_CHOMP => 1,
+        TRIM => 0,
         COMPILE_EXT => $this->cache ? '.ttc' : undef,
         COMPILE_DIR => $this->cache,
         INCLUDE_PATH => [$inc,@includes]
     );
     
+    $this->context->process($_) foreach $this->preprocess;
+    
     $this->template($this->context->template($fileName));
 }