Mercurial > pub > Impl
comparison Lib/IMPL/Web/View/TTControl.pm @ 343:9bdccdf1f50b
Added a templates context
author | cin |
---|---|
date | Fri, 13 Sep 2013 12:53:15 +0400 |
parents | 1090c1dd7429 |
children | f05634287ac7 |
comparison
equal
deleted
inserted
replaced
342:1090c1dd7429 | 343:9bdccdf1f50b |
---|---|
5 use IMPL::lang qw(:hash :base); | 5 use IMPL::lang qw(:hash :base); |
6 use Scalar::Util qw(blessed reftype); | 6 use Scalar::Util qw(blessed reftype); |
7 use IMPL::declare { | 7 use IMPL::declare { |
8 require => { | 8 require => { |
9 TemplateDocument => 'Template::Document', | 9 TemplateDocument => 'Template::Document', |
10 TTContext => 'Template::Context', | 10 TTContext => 'IMPL::Web::View::TTContext', |
11 Exception => 'IMPL::Exception', | 11 Exception => 'IMPL::Exception', |
12 ArgumentException => '-IMPL::InvalidArgumentException', | 12 ArgumentException => '-IMPL::InvalidArgumentException', |
13 OperationException => '-IMPL::InvalidOperationException' | 13 OperationException => '-IMPL::InvalidOperationException' |
14 }, | 14 }, |
15 base => [ | 15 base => [ |
136 } else { | 136 } else { |
137 die OperationException->new("The specified method '$method' doesn't exists"); | 137 die OperationException->new("The specified method '$method' doesn't exists"); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 sub CloneContext { | |
142 my ($this) = @_; | |
143 | |
144 $this->context->localise(); | |
145 | |
146 my $args = { %{$this->context} }; | |
147 delete $args->{CONFIG}; | |
148 | |
149 $this->context->delocalise(); | |
150 | |
151 return TTContext->new($args); | |
152 } | |
153 | |
154 sub CreateControlFromTemplate { | 141 sub CreateControlFromTemplate { |
155 my ($this,$template,$args) = @_; | 142 my ($this,$template,$args) = @_; |
156 | 143 |
157 if (not ref($template)) { | 144 if (not ref($template)) { |
158 return $this->context->stash->get([ | 145 return $this->context->stash->get([ |
161 ] | 148 ] |
162 ])->new($args); | 149 ])->new($args); |
163 } else { | 150 } else { |
164 return $this->new( | 151 return $this->new( |
165 $template, | 152 $template, |
166 $this->CloneContext(), | 153 $this->context->clone(), |
167 $args | 154 $args |
168 ); | 155 ); |
169 } | 156 } |
170 } | 157 } |
171 | 158 |