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