diff Lib/IMPL/Web/View/TTFactory.pm @ 192:a9faf883cdce

IMPL::Web::View refactoring
author cin
date Fri, 06 Apr 2012 16:22:38 +0400
parents 78a18a2b6266
children 4d0e1962161c
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTFactory.pm	Thu Apr 05 17:51:51 2012 +0400
+++ b/Lib/IMPL/Web/View/TTFactory.pm	Fri Apr 06 16:22:38 2012 +0400
@@ -5,6 +5,7 @@
 
 use IMPL::lang qw(:hash :declare :constants);
 use IMPL::Exception();
+use Scalar::Util qw(weaken);
 
 
 use parent qw(IMPL::Object::Factory);
@@ -25,12 +26,18 @@
 	die IMPL::ArgumentException("A template is required") unless $template;
 	
 	$options ||= {};
+	$context ||= new Template::Context($options);
 	
 	$this->template($template);
-	$this->context($context || new Template::Context($options));
-	$this->opts($options || {});
+	$this->context($context);
+	$this->opts($options);
 	$this->nodeProperties($nodeProps || {});
 	$this->instances(0);
+	
+	my $doc = delete $nodeProps->{document};
+	weaken($doc);
+	
+	$context->stash->set('require', sub { $doc->require(@_); } );
 }
 
 our %CTOR = (