diff Lib/IMPL/Web/View/TTDocument.pm @ 186:6c0fee769b0c

IMPL::Web::View::TTControl tests, fixes
author cin
date Fri, 30 Mar 2012 16:40:34 +0400
parents ae8072f2f2a3
children 927653d01f4f
line wrap: on
line diff
--- 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);
 		}