comparison Lib/IMPL/Web/View/TTFactory.pm @ 305:b5d5793f348e

TTView refactoring, still experiencing memory leaks
author sergey
date Wed, 17 Apr 2013 18:00:19 +0400
parents aeeb57a12046
children 5e4e7c8fbca1
comparison
equal deleted inserted replaced
304:2ff513227cb4 305:b5d5793f348e
25 template => PROP_RW, 25 template => PROP_RW,
26 context => PROP_RW, 26 context => PROP_RW,
27 instances => PROP_RW, 27 instances => PROP_RW,
28 baseLocation => PROP_RW, 28 baseLocation => PROP_RW,
29 base => PROP_RW, 29 base => PROP_RW,
30 require => PROP_RO, 30 registry => PROP_RO,
31 blocks => PROP_RO, 31 blocks => PROP_RO,
32 initialized => PROP_RO 32 initialized => PROP_RO
33 ] 33 ]
34 }; 34 };
35 35
36 sub CTOR { 36 sub CTOR {
37 my ($this,$template,$context,$baseLocation,$require) = @_; 37 my ($this,$template,$context,$path,$registry) = @_;
38 38
39 die ArgException->new("A template is required") unless $template; 39 die ArgException->new("A template is required") unless $template;
40 40
41 Loader->safe->Require($this->factory) 41 Loader->safe->Require($this->factory)
42 if $this->factory and not ref $this->factory; 42 if $this->factory and not ref $this->factory;
43 43
44 $context ||= new Template::Context(); 44 $context ||= new Template::Context();
45 my $baseLocation = join( '/', splice( @{[split(/\//,$path)]}, 0, -1 ) );
45 46
46 $this->template($template); 47 $this->template($template);
47 $this->context($context); 48 $this->context($context);
48 $this->baseLocation($baseLocation); 49 $this->baseLocation($baseLocation);
49 $this->instances(0); 50 $this->instances(0);
50 $this->require($require); 51 $this->registry($registry);
51 52
52 if (my $baseTplName = $template->extends) { 53 if (my $baseTplName = $template->extends) {
53 $baseTplName =~ s{^\./}{$baseLocation/}; 54 $baseTplName =~ s{^\./}{$baseLocation/};
54 55
55 my $base = &$require($baseTplName) 56 my $base = $registry->Require($baseTplName)
56 or die OpException->new("The specified base template isn't found"); 57 or die OpException->new("The specified base template isn't found");
57 58
58 $this->base($base); 59 $this->base($base);
59 60
60 $this->blocks(hashMerge($base->blocks, $template->blocks)); 61 $this->blocks(hashMerge($base->blocks, $template->blocks));
97 98
98 $context->stash->update({ require => sub { 99 $context->stash->update({ require => sub {
99 my ($module) = @_; 100 my ($module) = @_;
100 101
101 $module =~ s/^\.\//$baseLocation\//; 102 $module =~ s/^\.\//$baseLocation\//;
102 return $require->($module); 103 return $registry->Require($module);
103 }}); 104 }});
104 } 105 }
105 106
106 sub MergeParameters { 107 sub MergeParameters {
107 my $this = shift; 108 my $this = shift;