# HG changeset patch # User cin # Date 1367270825 -14400 # Node ID ec4ec1f056fe71da8de9337e6e495a409c9e3f28 # Parent 75a78cbf7dcf668040778cea4c11be389ede6ab2 TTView: page content now rendered lazy therefore a page layout must wrap the document content diff -r 75a78cbf7dcf -r ec4ec1f056fe Lib/IMPL/Web/View/TTDocument.pm --- 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); } }