diff Lib/IMPL/Web/TT/Document.pm @ 154:eb478083f72b

Url support
author wizard
date Thu, 30 Sep 2010 02:13:05 +0400
parents 4369d5458bb6
children 8638dd1374bf
line wrap: on
line diff
--- a/Lib/IMPL/Web/TT/Document.pm	Mon Sep 27 19:15:34 2010 +0400
+++ b/Lib/IMPL/Web/TT/Document.pm	Thu Sep 30 02:13:05 2010 +0400
@@ -20,6 +20,7 @@
     public property template => prop_get | owner_set;
     public property presenter => prop_all, { validate => \&_validatePresenter };
     public property preprocess => prop_all | prop_list,
+    public property title => prop_all;
     private property _controlClassMap => prop_all;
 }
 
@@ -163,7 +164,7 @@
 }
 
 sub LoadFile {
-    my ($this,$filePath,$encoding,@includes) = @_;
+    my ($this,$filePath,$encoding,$includes,$vars) = @_;
     
     die new IMPL::InvalidArgumentException("A filePath parameter is required") unless $filePath;
     
@@ -184,12 +185,26 @@
         TRIM => 0,
         COMPILE_EXT => $this->cache ? '.ttc' : undef,
         COMPILE_DIR => $this->cache,
-        INCLUDE_PATH => [$inc,@includes]
+        INCLUDE_PATH => [$inc,ref $includes ? @$includes : $includes ]
     );
     
+    if ($vars) {
+    	while ( my ($var,$val) = each %$vars ) {
+    		$this->AddVar($var,$val);
+    	}
+    }
+    
     $this->context->process($_) foreach $this->preprocess;
     
-    $this->template($this->context->template($fileName));
+    my $template = $this->context->template($fileName);
+    $this->title($template->title);
+    if ( $template->template ) {
+    	$this->context->process($template);
+    	$this->template($template->template);
+    } else {
+    	$this->template($template);
+    }
+    
 }
 
 sub AddVar {
@@ -198,14 +213,10 @@
 	$this->context->stash->set($name,$value);
 }
 
-sub title {
-    $_[0]->template->title;
-}
-
 sub Render {
     my ($this) = @_;
     
-    return $this->template->process($this->context);
+    return $this->context->process($this->template);
 }
 
 # Формирует представление для произвольных объектов 
@@ -248,10 +259,6 @@
 	return;
 }
 
-sub as_list {
-	$_[0]->childNodes;
-}
-
 sub Dispose {
     my ($this) = @_;