# HG changeset patch # User cin # Date 1363644157 -14400 # Node ID 78f76776570619bf4169fbf3138b3850983e8ff3 # Parent 52aae1b85084cc674594a5864c75f854bd7e7e72 TT view refactoring diff -r 52aae1b85084 -r 78f767765706 Lib/IMPL/Web/View/TTDocument.pm --- a/Lib/IMPL/Web/View/TTDocument.pm Mon Mar 11 01:22:24 2013 +0400 +++ b/Lib/IMPL/Web/View/TTDocument.pm Tue Mar 19 02:02:37 2013 +0400 @@ -67,17 +67,12 @@ if ( my $template = $self->loader->template($path) ) { $factory = new IMPL::Web::View::TTFactory( - $template->class || TTControl, $template, $documentContext, join( '/', splice( @{[split(/\//,$path)]}, 0, -1 ) ), $require ); - if ($template->class) { - Loader->safe->Require($template->class); - } - $controls{$control} = $factory; return $factory; diff -r 52aae1b85084 -r 78f767765706 Lib/IMPL/Web/View/TTFactory.pm --- a/Lib/IMPL/Web/View/TTFactory.pm Mon Mar 11 01:22:24 2013 +0400 +++ b/Lib/IMPL/Web/View/TTFactory.pm Tue Mar 19 02:02:37 2013 +0400 @@ -10,8 +10,13 @@ use IMPL::Const qw(:prop); use IMPL::declare { + require => { + Loader => 'IMPL::Code::Loader' + }, base => [ - 'IMPL::Object::Factory' => '@_' + 'IMPL::Object::Factory' => sub { + shift->class || 'IMPL::Web::View::TTControl' + } ], props => [ template => PROP_RW, @@ -23,10 +28,13 @@ }; sub CTOR { - my ($this,$factory,$template,$context,$base,$require) = @_; + my ($this,$template,$context,$base,$require) = @_; die IMPL::ArgumentException("A template is required") unless $template; + Loader->safe->Require($this->factory) + if $this->factory and not ref $this->factory; + $context ||= new Template::Context(); $this->template($template); @@ -36,12 +44,6 @@ $this->require($require); } -our %CTOR = ( - 'IMPL::Object::Factory' => sub { - $_[0] - } -); - sub MergeParameters { my ($this,$name,$refProps) = @_; @@ -50,6 +52,8 @@ $name = (ref $refProps eq 'HASH' and ($refProps->{name} || $refProps->{id})) || '*anonymous*'; } + $refProps->{factory} = $this; + my $base = $this->base; $this->context->localise();