# HG changeset patch # User cin # Date 1333111234 -14400 # Node ID 6c0fee769b0cdd6061bd32b80915ed8f9cf8e22d # Parent ae8072f2f2a33f0c01a9d1ed77ca9b5fe8d9e352 IMPL::Web::View::TTControl tests, fixes diff -r ae8072f2f2a3 -r 6c0fee769b0c Lib/IMPL/Object/Factory.pm --- a/Lib/IMPL/Object/Factory.pm Thu Mar 29 18:22:15 2012 +0400 +++ b/Lib/IMPL/Object/Factory.pm Fri Mar 30 16:40:34 2012 +0400 @@ -46,7 +46,7 @@ if (my $method = $this->method) { $this->factory->$method($this->MergeParameters(@_)); } else { - $this->factory->new($this->MergeParemeters(@_)); + $this->factory->new($this->MergeParameters(@_)); } } diff -r ae8072f2f2a3 -r 6c0fee769b0c Lib/IMPL/Web/View/TTControl.pm --- a/Lib/IMPL/Web/View/TTControl.pm Thu Mar 29 18:22:15 2012 +0400 +++ b/Lib/IMPL/Web/View/TTControl.pm Fri Mar 30 16:40:34 2012 +0400 @@ -59,7 +59,7 @@ my $res = $_[0]->template->$method(); - return defined($res) ? $res : $_[0]->context->stash->get($method); + return defined($res) ? $res : $_[0]->context->stash->get($method); } diff -r ae8072f2f2a3 -r 6c0fee769b0c Lib/IMPL/Web/View/TTDocument.pm --- a/Lib/IMPL/Web/View/TTDocument.pm Thu Mar 29 18:22:15 2012 +0400 +++ b/Lib/IMPL/Web/View/TTDocument.pm Fri Mar 30 16:40:34 2012 +0400 @@ -44,26 +44,30 @@ sub require { my ($this, $control) = @_; - if (! $this->controls->{$control}) { + if (my $factory = $this->controls->{$control}) { + return $factory; + } else { - (my $path = $control) =~ tr/\./\//; + my $path = $control; if ( my $template = $this->loader->template($path) ) { - my $opts = ${$this->opts}; + my $opts = { %{$this->opts} }; $opts->{STASH} = $this->context->stash->clone(); my $ctx = new Template::Context($opts); - my $factory = new IMPL::Web::View::TTFactory( + $factory = new IMPL::Web::View::TTFactory( typeof IMPL::Web::View::TTControl, $template, $ctx, $opts ); - my @parts = split(/\.+/,$control); + my @parts = split(/\/+/,$control); + $this->controls->{$control} = $factory; $this->context->stash->set([map { $_, 0 } @parts], $factory); - + + return $factory; } else { die new IMPL::KeyNotFoundException($control); } diff -r ae8072f2f2a3 -r 6c0fee769b0c Lib/IMPL/Web/View/TTFactory.pm --- a/Lib/IMPL/Web/View/TTFactory.pm Thu Mar 29 18:22:15 2012 +0400 +++ b/Lib/IMPL/Web/View/TTFactory.pm Fri Mar 30 16:40:34 2012 +0400 @@ -28,7 +28,7 @@ $this->template($template); $this->context($context || new Template::Context($options)); - $this->opts($options); + $this->opts($options || {}); $this->nodeProperties($nodeProps || {}); $this->instances(0); @@ -45,7 +45,7 @@ sub MergeParameters { my ($this,$name,$refProps) = @_; - my $opts = { $this->opts }; + my $opts = { %{ $this->opts } }; $opts->{STASH} = $opts->{STASH}->clone() if $opts->{STASH}; my $ctx = new Template::Context($opts); diff -r ae8072f2f2a3 -r 6c0fee769b0c _test/Resources/TTView.Output/Panel.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/_test/Resources/TTView.Output/Panel.txt Fri Mar 30 16:40:34 2012 +0400 @@ -0,0 +1,1 @@ +
diff -r ae8072f2f2a3 -r 6c0fee769b0c _test/Resources/TTView/My/Org/Panel.tt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/_test/Resources/TTView/My/Org/Panel.tt Fri Mar 30 16:40:34 2012 +0400 @@ -0,0 +1,15 @@ +[% + META version = 1; + BLOCK INIT; + dojoDefaultClass = 'dijit.form.Input'; + dojo.require.push( dojoDefaultClass ); + END; + BLOCK CTOR; + controlObject = this; + dojoClass = dojoDefaultClass; + visualClass = this.nodeProperty('visualClass') || 'classic'; + END; +%] +[% BLOCK RENDER %] +