comparison Lib/IMPL/Web/View/TTDocument.pm @ 311:d3b5a67ad2e8

sync
author cin
date Mon, 22 Apr 2013 03:42:53 +0400
parents 0a9d51cf6dfd
children ec4ec1f056fe
comparison
equal deleted inserted replaced
310:0a9d51cf6dfd 311:d3b5a67ad2e8
22 return $template, $ctx, $vars; # context 22 return $template, $ctx, $vars; # context
23 } 23 }
24 ], 24 ],
25 props => [ 25 props => [
26 layout => PROP_RW, 26 layout => PROP_RW,
27 layoutBase => PROP_RW,
28 registry => PROP_RW,
27 baseLocation => PROP_RW 29 baseLocation => PROP_RW
28 ] 30 ]
29 }; 31 };
30 32
31 sub CTOR { 33 sub CTOR {
32 my ($this,$template,$ctx,$vars) = @_; 34 my ($this,$template,$ctx) = @_;
33 35
34 $this->layout( $template->layout ) unless $this->layout; 36 $this->layout( $template->layout ) unless $this->layout;
35 $this->title( $template->title ) unless $this->title; 37 $this->title( $template->title ) unless $this->title;
36 38 my $doc = $this;
37 $this->context->stash->update($vars) 39 weaken($doc);
38 if ref $vars eq 'HASH'; 40 $this->registry->context->stash->update({
41 document => sub { $doc }
42 });
39 } 43 }
40 44
41 sub Render { 45 sub Render {
42 my ($this,$args) = @_; 46 my ($this,$args) = @_;
43 47
44 $args ||= {}; 48 $args ||= {};
45 $args->{document} = $this; 49 $args->{document} = $this;
46 50
47 $this->context->stash->update({ 51 #$this->context->stash->update({
48 document => sub { $this } 52 # document => sub { $this }
49 }); 53 #});
50 54
51 my $text = eval { 55 my $text = eval {
52 56
53 if ($this->layout) { 57 if ($this->layout) {
54 my $layout = $this->registry->Require(join('/',$this->layoutBase, $this->layout))->new(); 58 my $layout = $this->registry->Require(join('/',$this->layoutBase, $this->layout))->new();
64 } 68 }
65 }; 69 };
66 70
67 my $e = $@; 71 my $e = $@;
68 72
69 undef $this; 73 # undef $this;
70 74
71 if ($e) { 75 if ($e) {
72 die $e; 76 die $e;
73 } else { 77 } else {
74 return $text; 78 return $text;