changeset 313:ec4ec1f056fe

TTView: page content now rendered lazy therefore a page layout must wrap the document content
author cin
date Tue, 30 Apr 2013 01:27:05 +0400
parents 75a78cbf7dcf
children 109f28643025
files Lib/IMPL/Web/View/TTDocument.pm
diffstat 1 files changed, 11 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTDocument.pm	Mon Apr 29 01:10:42 2013 +0400
+++ b/Lib/IMPL/Web/View/TTDocument.pm	Tue Apr 30 01:27:05 2013 +0400
@@ -48,34 +48,19 @@
     $args ||= {};
     $args->{document} = $this;
     
-    #$this->context->stash->update({
-    #	document => sub { $this }
-    #});
     
-    my $text = eval {
-    
-        if ($this->layout) {
-        	my $layout = $this->registry->Require(join('/',$this->layoutBase, $this->layout))->new();
-        	
-        	my $content = $this->next::method($args);
-        	return $layout->Render({
-                content => $content,
-                template => $this->template,
-                document => $this
-            });
-	    } else {
-	        return $this->next::method($args);
-	    }
-    };
-    
-    my $e = $@;
-    
-    # undef $this;
-    
-    if ($e) {
-        die $e;
+    if ($this->layout) {
+    	my $layout = $this->registry->Require(join('/',$this->layoutBase, $this->layout))->new();
+    	
+    	my $next = $this->next::can();
+    	
+    	return $layout->Render({
+            content => sub { $this->$next($args) },
+            template => $this->template,
+            document => $this
+        });
     } else {
-        return $text;
+        return $this->next::method($args);
     }
 }