diff Lib/IMPL/Web/View/TTLoader.pm @ 195:7a920771fd8e

IMPL::Web::View changed document layout handling, docs, examples
author cin
date Wed, 11 Apr 2012 17:50:33 +0400
parents 4d0e1962161c
children a705e848dcc7
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTLoader.pm	Tue Apr 10 20:08:29 2012 +0400
+++ b/Lib/IMPL/Web/View/TTLoader.pm	Wed Apr 11 17:50:33 2012 +0400
@@ -18,6 +18,7 @@
     public property provider => PROP_GET | PROP_OWNERSET;
     public property context => PROP_GET | PROP_OWNERSET;
     public property ext => PROP_ALL;
+    public property layoutBase => PROP_GET | PROP_OWNERSET;
     
     public property isInitialized => PROP_GET | PROP_OWNERSET;
     public property initializer => PROP_GET | PROP_OWNERSET;
@@ -35,6 +36,7 @@
     $this->_globals(ref $args{globals} eq 'HASH' ? $args{globals} : {});
     
     $this->options($refOpts);
+    $this->layoutBase($args{layoutBase}) if $args{layoutBase};
     
     # to aviod cyclic references we need to do a copy of $refOpts
     $refOpts->{LOAD_TEMPLATES} = $this->provider(new Template::Provider( { %$refOpts } ));
@@ -77,6 +79,19 @@
     return $tt;
 }
 
+sub layout {
+	my ($this,$name) = @_;
+	
+	my $layout;
+	
+	if ($this->layoutBase) {
+		$layout = $this->layoutBase . "/";
+	}
+	
+	$layout .= $name;
+	return $this->template($layout);
+}
+
 sub _appendExt {
     my ($this,$name) = @_;