diff Lib/IMPL/Web/View/TTView.pm @ 353:feeb3bc4a818

corrected error handling while loading templates corrected variables lookup in controls updated handles to use the new view features
author cin
date Fri, 11 Oct 2013 15:49:04 +0400
parents cfd7570c2af2
children 9330835535b9
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTView.pm	Thu Oct 10 19:51:19 2013 +0400
+++ b/Lib/IMPL/Web/View/TTView.pm	Fri Oct 11 15:49:04 2013 +0400
@@ -1,6 +1,7 @@
 package IMPL::Web::View::TTView;
 use strict;
 
+use IMPL::lang qw(hashMerge);
 use IMPL::Const qw(:prop);
 use IMPL::declare {
 	require => {
@@ -13,10 +14,12 @@
 	],
 	props => [
 		options => PROP_RW,
-		view => PROP_RW,
+		viewBase => PROP_RW,
+		layoutBase => PROP_RW,
 		layout => PROP_RW,
 		tt_ext => PROP_RW,
-		includes => PROP_RW | PROP_LIST
+		includes => PROP_RW | PROP_LIST,
+		globals => PROP_RW
 	]
 };
 
@@ -30,7 +33,7 @@
 	my ($this,$model,$template,$args) = @_;
 	
 	my $context = Context->new($this->options);
-	my $layout = delete $args->{layout};
+	my $layout = delete $args->{layout} || $this->layout;
 	
 	return $context->invoke_environment(
 		sub {
@@ -41,14 +44,14 @@
 						return $ctx->render($layout,$args);
 					},
 					{
-						base => $this->layout,
+						base => $this->layoutBase,
 						content => sub {
 							$ctx->invoke_environment(
 								sub {
-									return shift->display($model,$template,$args);
+									return shift->display_model($model,$template,$args);
 								},
 								{
-									base => $this->view
+									base => $this->viewBase
 								}
 							)
 						}
@@ -57,21 +60,24 @@
 			} else {
 				return $ctx->invoke_environment(
 					sub {
-						return $ctx->display($model,$template,$args);
+						return $ctx->display_model($model,$template,$args);
 					},
 					{
-						base => $this->view
+						base => $this->viewBase
 					}
 				);
 			}
-		},{
-			includes => scalar($this->includes),
-			tt_ext => 'tt',
-			document => {},
-			debug => sub {
-				warn @_;
-			}
-		}
+		},hashMerge(
+			{
+				includes => scalar($this->includes),
+				tt_ext => $this->tt_ext,
+				document => {},
+				debug => sub {
+					warn @_;
+				}
+			},
+			$this->globals
+		)
 	);
 }