diff Lib/IMPL/Web/View/TTDocument.pm @ 310:0a9d51cf6dfd

*TTView: refactoring, document supports custom classes, layouts are become controls
author sergey
date Fri, 19 Apr 2013 16:39:01 +0400
parents 5e4e7c8fbca1
children d3b5a67ad2e8
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTDocument.pm	Fri Apr 19 00:27:51 2013 +0400
+++ b/Lib/IMPL/Web/View/TTDocument.pm	Fri Apr 19 16:39:01 2013 +0400
@@ -42,10 +42,8 @@
     my ($this,$args) = @_;
 
     $args ||= {};
+    $args->{document} = $this;
     
-    $this->context->localise(); # localise stash
-    my $documentContext = _clone_context( $this->context ); # create a new context
-
     $this->context->stash->update({
     	document => sub { $this }
     });
@@ -53,37 +51,20 @@
     my $text = eval {
     
         if ($this->layout) {
-        	my $tlayout = $this->registry->loader->layout($this->layout)
-        	   or die OpException->new('The specified layout isn\'t found', $this->layout);
-        	if(my $init = $tlayout->blocks->{INIT}) {
-        		$this->context->process(
-                    $init,
-                    hashMerge(
-                        $args,
-                        {
-                           	template => $this->template
-                        }
-                    )
-                );
-        	}
+        	my $layout = $this->registry->Require(join('/',$this->layoutBase, $this->layout))->new();
+        	
         	my $content = $this->next::method($args);
-            return $this->context->include(
-                $tlayout,
-                {
-                	%{$args},
-                    content => $content,
-                    this => $this,
-                    template => $this->template
-                }
-            );
+        	return $layout->Render({
+                content => $content,
+                template => $this->template,
+                document => $this
+            });
 	    } else {
 	        return $this->next::method($args);
 	    }
     };
     
     my $e = $@;
-
-    $this->context->delocalise();
     
     undef $this;