diff Lib/IMPL/Web/View/TTLoader.pm @ 309:5e4e7c8fbca1

sync
author cin
date Fri, 19 Apr 2013 00:27:51 +0400
parents 47a09a8dc23a
children 0a9d51cf6dfd
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTLoader.pm	Thu Apr 18 20:06:05 2013 +0400
+++ b/Lib/IMPL/Web/View/TTLoader.pm	Fri Apr 19 00:27:51 2013 +0400
@@ -8,7 +8,9 @@
     require => {
         Provider => 'Template::Provider',
         Context => 'Template::Context',
+        TTRegistry => 'IMPL::Web::View::TTRegistry',
         TTFactory => 'IMPL::Web::View::TTFactory',
+        TTDocument => '-IMPL::Web::View::TTDocument',
         Exception => 'IMPL::Exception',
         ArgumentException => '-IMPL::InvalidArgumentException',
         KeyNotFoundException => '-IMPL::KeyNotFoundException'
@@ -71,7 +73,7 @@
 sub document {
     my ($this,$name,$vars) = @_;
     
-    $vars ||= $vars;
+    $vars ||= {};
     
     my $tt = $this->template($name);
         
@@ -83,9 +85,13 @@
     my $ctx = _clone_context($this->context);
     $this->context->delocalise();
     
-    my $factory = TTFactory->new($tt,$ctx,$name,TTRegistry->new($this, $ctx));
+    my $registry = TTRegistry->new($this, $ctx);
+    
+    my $factory = TTFactory->new($tt->class || TTDocument, $tt, $ctx, $name, $registry);
     
-    return $factory->new( $vars );
+    $vars->{registry} = $registry;
+    
+    return $factory->new( $vars );    
 }