diff Lib/IMPL/Web/View/TTDocument.pm @ 308:47a09a8dc23a

sync
author sergey
date Thu, 18 Apr 2013 20:06:05 +0400
parents 2da2564f115d
children 5e4e7c8fbca1
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTDocument.pm	Thu Apr 18 02:21:28 2013 +0400
+++ b/Lib/IMPL/Web/View/TTDocument.pm	Thu Apr 18 20:06:05 2013 +0400
@@ -23,15 +23,13 @@
     ],
     props => [
         layout => PROP_RW,
-        loader => PROP_RW,
         baseLocation => PROP_RW
     ]
 };
 
 sub CTOR {
-    my ($this,$template,$ctx,$loader,$vars) = @_;
+    my ($this,$template,$ctx,$vars) = @_;
     
-    $this->loader($loader) if $loader;
     $this->layout( $template->layout ) unless $this->layout;
     $this->title( $template->title ) unless $this->title;
     
@@ -46,18 +44,15 @@
     
     $this->context->localise(); # localise stash
     my $documentContext = _clone_context( $this->context ); # create a new context
-    
-    my $registry = TTRegistry->new($this->loader, $documentContext);
 
     $this->context->stash->update({
-    	require => sub { $registry->Require(shift) },
     	document => sub { $this }
     });
     
     my $text = eval {
     
         if ($this->layout) {
-        	my $tlayout = $this->loader->layout($this->layout);
+        	my $tlayout = $this->GetTemplate($this->layout);
         	if(my $init = $tlayout->blocks->{INIT}) {
         		$this->context->process(
                     $init,
@@ -86,8 +81,6 @@
     
     my $e = $@;
 
-    $registry->Dispose();
-    undef $registry;    
     $this->context->delocalise();
     
     undef $this;
@@ -105,6 +98,12 @@
     $this->template->blocks->{$name};
 }
 
+sub DTOR {
+	my $this = shift;
+	
+	$this->registry->Dispose() if $this->registry;
+}
+
 sub _clone_context {
     my $args = { %{shift || {}} };
     delete $args->{CONFIG};