comparison _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
comparison
equal deleted inserted replaced
350:f356c4894d1b 351:cfd7570c2af2
1 #!/usr/bin/perl 1 #!/usr/bin/perl
2 use strict; 2 use strict;
3 3
4 use IMPL::require { 4 use IMPL::require {
5 TTContext => 'IMPL::Web::View::TTContext' 5 TTView => 'IMPL::Web::View::TTView'
6 }; 6 };
7 7
8 my $ctx = TTContext->new({ 8 use Time::HiRes qw(gettimeofday tv_interval);
9 INCLUDE_PATH => './Resources/view',
10 INTERPOLATE => 1,
11 RECURSION => 1000
12 });
13 9
14 print $ctx->invoke_environment(sub { 10 my $t = [gettimeofday];
15 my ($this) = @_; 11
16 return $this->render( 12 my $view = TTView->new(
17 'default', 13 options => {
18 { 14 INCLUDE_PATH => './Resources/view',
19 content => sub { 15 INTERPOLATE => 1,
20 return $this->invoke_environment( 16 RECURSION => 1000
21 sub { 17 },
22 shift->render( 18 view => 'site',
23 'product/view', 19 layout => 'layout',
24 {
25 model => {
26 name => 'debugger',
27 manufature => {
28 name => 'DEBUGGERS INC',
29 address => [
30 {
31 coutry => 'Russuia',
32 city => 'Moscow'
33 },
34 {
35 country => 'GB',
36 city => 'Essex'
37 }
38 ]
39 }
40 }
41 }
42 );
43 }, {
44 base => 'site'
45 }
46 );
47 }
48 }
49 );
50 }, {
51 base => 'layout',
52 includes => [ 20 includes => [
53 'packages' 21 'packages'
54 ], 22 ]
55 tt_ext => 'tt', 23 );
56 document => { 24
57 title => 'Test document' 25 print $view->display(
58 } 26 {
59 }); 27 name => 'debugger',
28 manufacture => {
29 name => 'DEBUGGERS INC',
30 address => [
31 {
32 coutry => 'Russuia',
33 city => 'Moscow'
34 },
35 {
36 country => 'GB',
37 city => 'Essex'
38 }
39 ]
40 }
41 },
42 'product/view',
43 { layout => 'default' }
44 ), "\n";
45
46 print "render page: ",tv_interval($t,[gettimeofday]),"ms\n";
60 47