comparison Lib/IMPL/Web/View/TTFactory.pm @ 287:2d253e6e4a88

*TTView refactoring
author cin
date Tue, 19 Feb 2013 03:05:10 +0400
parents c6d0f889ef87
children 3a9cfea098dd
comparison
equal deleted inserted replaced
286:d357b5d85d25 287:2d253e6e4a88
14 'IMPL::Object::Factory' => '@_' 14 'IMPL::Object::Factory' => '@_'
15 ], 15 ],
16 props => [ 16 props => [
17 template => PROP_RW, 17 template => PROP_RW,
18 context => PROP_RW, 18 context => PROP_RW,
19 opts => PROP_RW,
20 instances => PROP_RW, 19 instances => PROP_RW,
21 base => PROP_RW 20 base => PROP_RW
22 ] 21 ]
23 }; 22 };
24 23
25 sub CTOR { 24 sub CTOR {
26 my ($this,$factory,$template,$context,$options,$base) = @_; 25 my ($this,$factory,$template,$context,$base) = @_;
27 26
28 die IMPL::ArgumentException("A template is required") unless $template; 27 die IMPL::ArgumentException("A template is required") unless $template;
29 28
30 $options ||= {}; 29 $context ||= new Template::Context();
31 $context ||= new Template::Context($options);
32 30
33 $this->template($template); 31 $this->template($template);
34 $this->context($context); 32 $this->context($context);
35 $this->opts($options);
36 $this->base($base); 33 $this->base($base);
37 $this->instances(0); 34 $this->instances(0);
38 } 35 }
39 36
40 our %CTOR = ( 37 our %CTOR = (
44 ); 41 );
45 42
46 sub MergeParameters { 43 sub MergeParameters {
47 my ($this,$name,$refProps) = @_; 44 my ($this,$name,$refProps) = @_;
48 45
49 my $opts = { %{ $this->opts } };
50 $opts->{STASH} = $opts->{STASH}->clone() if $opts->{STASH};
51
52 my $base = $this->base; 46 my $base = $this->base;
53 47
54 my $ctx = new Template::Context($opts); 48 $this->context->localise();
49
50 my $ctx = new Template::Context({ %{$this->context} });
51
52 $this->context->delocalise();
55 53
56 my $stash = $ctx->stash; 54 my $stash = $ctx->stash;
57 weaken($stash); 55 weaken($stash);
58 56
59 $stash->update({ 57 $stash->update({