comparison 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
comparison
equal deleted inserted replaced
352:675cd1829255 353:feeb3bc4a818
1 package IMPL::Web::View::TTView; 1 package IMPL::Web::View::TTView;
2 use strict; 2 use strict;
3 3
4 use IMPL::lang qw(hashMerge);
4 use IMPL::Const qw(:prop); 5 use IMPL::Const qw(:prop);
5 use IMPL::declare { 6 use IMPL::declare {
6 require => { 7 require => {
7 Context => 'IMPL::Web::View::TTContext' 8 Context => 'IMPL::Web::View::TTContext'
8 }, 9 },
11 'IMPL::Object::Autofill' => '@_', 12 'IMPL::Object::Autofill' => '@_',
12 'IMPL::Object::Serializable' => undef 13 'IMPL::Object::Serializable' => undef
13 ], 14 ],
14 props => [ 15 props => [
15 options => PROP_RW, 16 options => PROP_RW,
16 view => PROP_RW, 17 viewBase => PROP_RW,
18 layoutBase => PROP_RW,
17 layout => PROP_RW, 19 layout => PROP_RW,
18 tt_ext => PROP_RW, 20 tt_ext => PROP_RW,
19 includes => PROP_RW | PROP_LIST 21 includes => PROP_RW | PROP_LIST,
22 globals => PROP_RW
20 ] 23 ]
21 }; 24 };
22 25
23 sub CTOR { 26 sub CTOR {
24 my ($this) = @_; 27 my ($this) = @_;
28 31
29 sub display { 32 sub display {
30 my ($this,$model,$template,$args) = @_; 33 my ($this,$model,$template,$args) = @_;
31 34
32 my $context = Context->new($this->options); 35 my $context = Context->new($this->options);
33 my $layout = delete $args->{layout}; 36 my $layout = delete $args->{layout} || $this->layout;
34 37
35 return $context->invoke_environment( 38 return $context->invoke_environment(
36 sub { 39 sub {
37 my $ctx = shift; 40 my $ctx = shift;
38 if ($layout) { 41 if ($layout) {
39 return $ctx->invoke_environment( 42 return $ctx->invoke_environment(
40 sub { 43 sub {
41 return $ctx->render($layout,$args); 44 return $ctx->render($layout,$args);
42 }, 45 },
43 { 46 {
44 base => $this->layout, 47 base => $this->layoutBase,
45 content => sub { 48 content => sub {
46 $ctx->invoke_environment( 49 $ctx->invoke_environment(
47 sub { 50 sub {
48 return shift->display($model,$template,$args); 51 return shift->display_model($model,$template,$args);
49 }, 52 },
50 { 53 {
51 base => $this->view 54 base => $this->viewBase
52 } 55 }
53 ) 56 )
54 } 57 }
55 } 58 }
56 ); 59 );
57 } else { 60 } else {
58 return $ctx->invoke_environment( 61 return $ctx->invoke_environment(
59 sub { 62 sub {
60 return $ctx->display($model,$template,$args); 63 return $ctx->display_model($model,$template,$args);
61 }, 64 },
62 { 65 {
63 base => $this->view 66 base => $this->viewBase
64 } 67 }
65 ); 68 );
66 } 69 }
67 },{ 70 },hashMerge(
68 includes => scalar($this->includes), 71 {
69 tt_ext => 'tt', 72 includes => scalar($this->includes),
70 document => {}, 73 tt_ext => $this->tt_ext,
71 debug => sub { 74 document => {},
72 warn @_; 75 debug => sub {
73 } 76 warn @_;
74 } 77 }
78 },
79 $this->globals
80 )
75 ); 81 );
76 } 82 }
77 83
78 1; 84 1;