comparison Lib/IMPL/Web/View/TTDocument.pm @ 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 d3b5a67ad2e8
children 9bdccdf1f50b
comparison
equal deleted inserted replaced
312:75a78cbf7dcf 313:ec4ec1f056fe
46 my ($this,$args) = @_; 46 my ($this,$args) = @_;
47 47
48 $args ||= {}; 48 $args ||= {};
49 $args->{document} = $this; 49 $args->{document} = $this;
50 50
51 #$this->context->stash->update({
52 # document => sub { $this }
53 #});
54 51
55 my $text = eval { 52 if ($this->layout) {
56 53 my $layout = $this->registry->Require(join('/',$this->layoutBase, $this->layout))->new();
57 if ($this->layout) { 54
58 my $layout = $this->registry->Require(join('/',$this->layoutBase, $this->layout))->new(); 55 my $next = $this->next::can();
59 56
60 my $content = $this->next::method($args); 57 return $layout->Render({
61 return $layout->Render({ 58 content => sub { $this->$next($args) },
62 content => $content, 59 template => $this->template,
63 template => $this->template, 60 document => $this
64 document => $this 61 });
65 });
66 } else {
67 return $this->next::method($args);
68 }
69 };
70
71 my $e = $@;
72
73 # undef $this;
74
75 if ($e) {
76 die $e;
77 } else { 62 } else {
78 return $text; 63 return $this->next::method($args);
79 } 64 }
80 } 65 }
81 66
82 sub GetTemplate { 67 sub GetTemplate {
83 my ($this,$name) = @_; 68 my ($this,$name) = @_;