comparison Lib/IMPL/Web/View/TTFactory.pm @ 288:3a9cfea098dd

*TTView refactoring: removed RequireControl method, etc.
author sergey
date Tue, 19 Feb 2013 19:58:27 +0400
parents 2d253e6e4a88
children 85572f512abc
comparison
equal deleted inserted replaced
287:2d253e6e4a88 288:3a9cfea098dd
15 ], 15 ],
16 props => [ 16 props => [
17 template => PROP_RW, 17 template => PROP_RW,
18 context => PROP_RW, 18 context => PROP_RW,
19 instances => PROP_RW, 19 instances => PROP_RW,
20 base => PROP_RW 20 base => PROP_RW,
21 require => PROP_RO
21 ] 22 ]
22 }; 23 };
23 24
24 sub CTOR { 25 sub CTOR {
25 my ($this,$factory,$template,$context,$base) = @_; 26 my ($this,$factory,$template,$context,$base,$require) = @_;
26 27
27 die IMPL::ArgumentException("A template is required") unless $template; 28 die IMPL::ArgumentException("A template is required") unless $template;
28 29
29 $context ||= new Template::Context(); 30 $context ||= new Template::Context();
30 31
31 $this->template($template); 32 $this->template($template);
32 $this->context($context); 33 $this->context($context);
33 $this->base($base); 34 $this->base($base);
34 $this->instances(0); 35 $this->instances(0);
36 $this->require($require);
35 } 37 }
36 38
37 our %CTOR = ( 39 our %CTOR = (
38 'IMPL::Object::Factory' => sub { 40 'IMPL::Object::Factory' => sub {
39 $_[0] 41 $_[0]
50 my $ctx = new Template::Context({ %{$this->context} }); 52 my $ctx = new Template::Context({ %{$this->context} });
51 53
52 $this->context->delocalise(); 54 $this->context->delocalise();
53 55
54 my $stash = $ctx->stash; 56 my $stash = $ctx->stash;
55 weaken($stash); 57 my $require = $this->require;
56 58
57 $stash->update({ 59 $stash->update({
58 require => sub { 60 require => sub {
59 my ($module) = @_; 61 my ($module) = @_;
60 62
61 $module =~ s/^\.\//$base\//; 63 $module =~ s/^\.\//$base\//;
62 return $stash->get('document')->RequireControl($module); 64 return $require->($module);
63 } 65 }
64 }); 66 });
65 67
66 return ($name, $this->template, $ctx, hashApply({ factory => $this },$refProps)); 68 return ($name, $this->template, $ctx, hashApply({ factory => $this },$refProps));
67 } 69 }