diff _test/temp.pl @ 351:cfd7570c2af2

working on TTView: created TTView class for rendering models
author cin
date Tue, 08 Oct 2013 17:40:35 +0400
parents f356c4894d1b
children 675cd1829255
line wrap: on
line diff
--- a/_test/temp.pl	Mon Oct 07 17:35:54 2013 +0400
+++ b/_test/temp.pl	Tue Oct 08 17:40:35 2013 +0400
@@ -2,59 +2,46 @@
 use strict;
 
 use IMPL::require {
-	TTContext => 'IMPL::Web::View::TTContext'
+	TTView => 'IMPL::Web::View::TTView'
 };
 
-my $ctx = TTContext->new({
-	INCLUDE_PATH => './Resources/view',
-	INTERPOLATE => 1,
-	RECURSION => 1000
-});
+use Time::HiRes qw(gettimeofday tv_interval);
+
+my $t = [gettimeofday];
+
+my $view = TTView->new(
+	options => {
+		INCLUDE_PATH => './Resources/view',
+		INTERPOLATE => 1,
+		RECURSION => 1000
+	},
+	view => 'site',
+	layout => 'layout',
+	includes => [
+		'packages'
+	]
+);
 
-print $ctx->invoke_environment(sub {
-	my ($this) = @_;
-	return $this->render(
-	    'default',
-	    {
-	    	content => sub {
-	    		return $this->invoke_environment(
-	    		    sub {
-		    			shift->render(
-			                'product/view',
-			                {
-					            model => {
-								    name => 'debugger',
-								    manufature => {
-										name => 'DEBUGGERS INC',
-										address => [
-										     {
-										     	coutry => 'Russuia',
-										     	city => 'Moscow'
-										     },
-										     {
-										     	country => 'GB',
-										     	city => 'Essex'
-										     }
-										]
-								    }
-					            }				            
-						    }
-						);
-		    		}, {
-		    			base => 'site'
-		    		}
-                );
-		    }
-	    }
-    );
-}, {
-	base => 'layout',
-	includes => [
-	   'packages'
-	],
-	tt_ext => 'tt',
-	document => {
-		title => 'Test document'
-	}
-});
+print $view->display(
+	{
+		name => 'debugger',
+		manufacture => {
+			name => 'DEBUGGERS INC',
+			address => [
+				{
+					coutry => 'Russuia',
+					city => 'Moscow'
+				},
+				{
+					country => 'GB',
+					city => 'Essex'
+				}
+			]
+		}
+	},
+	'product/view',
+	{ layout => 'default' }
+), "\n";
+
+print "render page: ",tv_interval($t,[gettimeofday]),"ms\n";