comparison Lib/IMPL/Web/View/TTFactory.pm @ 289:85572f512abc

*TTView refactoring
author cin
date Wed, 20 Feb 2013 02:25:30 +0400
parents 3a9cfea098dd
children 7b0dad6117d5
comparison
equal deleted inserted replaced
288:3a9cfea098dd 289:85572f512abc
47 47
48 my $base = $this->base; 48 my $base = $this->base;
49 49
50 $this->context->localise(); 50 $this->context->localise();
51 51
52 my $ctx = new Template::Context({ %{$this->context} }); 52 my $ctx = _clone_context($this->context);
53 53
54 $this->context->delocalise(); 54 $this->context->delocalise();
55 55
56 my $stash = $ctx->stash; 56 my $stash = $ctx->stash;
57 my $require = $this->require; 57 my $require = $this->require;
58 58
59 $stash->update({ 59 $stash->update({
60 require => sub { 60 require => sub {
61 my ($module) = @_; 61 my ($module) = @_;
62 62
63 $module =~ s/^\.\//$base\//; 63 $module =~ s/^\.\//$base\//;
64 return $require->($module); 64 return $require->($module);
65 } 65 }
66 }); 66 });
67 67
68 return ($name, $this->template, $ctx, hashApply({ factory => $this },$refProps)); 68 return ($name, $this->template, $ctx, $refProps);
69 } 69 }
70 70
71 sub CreateObject { 71 sub CreateObject {
72 my $this = shift; 72 my $this = shift;
73 73
86 86
87 $count++; 87 $count++;
88 $this->instances($count); 88 $this->instances($count);
89 89
90 return $instance; 90 return $instance;
91 }
92
93 sub _clone_context {
94 my $args = { %{shift || {}} };
95 delete $args->{CONFIG};
96
97 return Template::Context->new($args);
91 } 98 }
92 99
93 sub save { 100 sub save {
94 die new IMPL::NotImplementedException("This class doesn't support serialization"); 101 die new IMPL::NotImplementedException("This class doesn't support serialization");
95 } 102 }