Mercurial > pub > Impl
comparison 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 |
comparison
equal
deleted
inserted
replaced
309:5e4e7c8fbca1 | 310:0a9d51cf6dfd |
---|---|
40 | 40 |
41 sub Render { | 41 sub Render { |
42 my ($this,$args) = @_; | 42 my ($this,$args) = @_; |
43 | 43 |
44 $args ||= {}; | 44 $args ||= {}; |
45 $args->{document} = $this; | |
45 | 46 |
46 $this->context->localise(); # localise stash | |
47 my $documentContext = _clone_context( $this->context ); # create a new context | |
48 | |
49 $this->context->stash->update({ | 47 $this->context->stash->update({ |
50 document => sub { $this } | 48 document => sub { $this } |
51 }); | 49 }); |
52 | 50 |
53 my $text = eval { | 51 my $text = eval { |
54 | 52 |
55 if ($this->layout) { | 53 if ($this->layout) { |
56 my $tlayout = $this->registry->loader->layout($this->layout) | 54 my $layout = $this->registry->Require(join('/',$this->layoutBase, $this->layout))->new(); |
57 or die OpException->new('The specified layout isn\'t found', $this->layout); | 55 |
58 if(my $init = $tlayout->blocks->{INIT}) { | |
59 $this->context->process( | |
60 $init, | |
61 hashMerge( | |
62 $args, | |
63 { | |
64 template => $this->template | |
65 } | |
66 ) | |
67 ); | |
68 } | |
69 my $content = $this->next::method($args); | 56 my $content = $this->next::method($args); |
70 return $this->context->include( | 57 return $layout->Render({ |
71 $tlayout, | 58 content => $content, |
72 { | 59 template => $this->template, |
73 %{$args}, | 60 document => $this |
74 content => $content, | 61 }); |
75 this => $this, | |
76 template => $this->template | |
77 } | |
78 ); | |
79 } else { | 62 } else { |
80 return $this->next::method($args); | 63 return $this->next::method($args); |
81 } | 64 } |
82 }; | 65 }; |
83 | 66 |
84 my $e = $@; | 67 my $e = $@; |
85 | |
86 $this->context->delocalise(); | |
87 | 68 |
88 undef $this; | 69 undef $this; |
89 | 70 |
90 if ($e) { | 71 if ($e) { |
91 die $e; | 72 die $e; |