diff Lib/IMPL/Web/View/TTView.pm @ 359:833e663796c4

TTView: added view variable to pass rendering context between controls TTView: display function renamed to display_for WebResource: resources now marked with roles for searching a desired resource by a role in the resource chain
author sergey
date Mon, 25 Nov 2013 02:19:31 +0400
parents 9330835535b9
children d5c8b955bf8d
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTView.pm	Mon Nov 18 01:25:35 2013 +0400
+++ b/Lib/IMPL/Web/View/TTView.pm	Mon Nov 25 02:19:31 2013 +0400
@@ -1,11 +1,13 @@
 package IMPL::Web::View::TTView;
 use strict;
 
-use IMPL::lang qw(hashMerge);
+use JSON;
+use IMPL::lang qw(hashMerge is);
 use IMPL::Const qw(:prop);
 use IMPL::declare {
 	require => {
-		Context => 'IMPL::Web::View::TTContext'
+		Context => 'IMPL::Web::View::TTContext',
+		Loader  => 'IMPL::Code::Loader'
 	},
 	base => [
 		'IMPL::Object' => undef,
@@ -44,12 +46,11 @@
 						return shift->render(
 							$layout,
 							hashMerge(
-								$args,
 								{
 									content => sub {
 										$ctx->invoke_environment(
 											sub {
-												return shift->display_model($model,$template,$args);
+												return shift->display_model($model,$template);
 											},
 											{
 												base => $this->viewBase
@@ -67,7 +68,7 @@
 			} else {
 				return $ctx->invoke_environment(
 					sub {
-						return shift->display_model($model,$template,$args);
+						return shift->display_model($model,$template);
 					},
 					{
 						base => $this->viewBase
@@ -75,15 +76,26 @@
 				);
 			}
 		},hashMerge(
-			{
-				includes => scalar($this->includes),
-				tt_ext => $this->tt_ext,
-				document => {},
-				debug => sub {
-					warn @_;
+			$this->globals,
+			hashMerge(
+				$args,
+				{
+					includes => scalar($this->includes),
+					tt_ext => $this->tt_ext,
+					debug => sub {
+						warn @_;
+					},
+					is => sub {
+						return is(shift,shift);
+					},
+					import => sub {
+						return Loader->safe->Require(shift);
+					},
+					toJSON => sub {
+						return JSON->new()->utf8->pretty->encode(shift);
+					}
 				}
-			},
-			$this->globals
+			)
 		)
 	);
 }