comparison Lib/IMPL/Web/View/TTControl.pm @ 342:1090c1dd7429

TTControl: added a helper method 'CreateControlFromTemlpate'
author cin
date Wed, 03 Jul 2013 03:53:12 +0400
parents 71221d79e6b4
children 9bdccdf1f50b
comparison
equal deleted inserted replaced
341:70658970af15 342:1090c1dd7429
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 {
155 my ($this,$template,$args) = @_;
156
157 if (not ref($template)) {
158 return $this->context->stash->get([
159 require => [
160 $template
161 ]
162 ])->new($args);
163 } else {
164 return $this->new(
165 $template,
166 $this->CloneContext(),
167 $args
168 );
169 }
170 }
171
141 1; 172 1;
142 173
143 __END__ 174 __END__
144 175
145 =pod 176 =pod