Mercurial > pub > Impl
annotate Lib/IMPL/Web/View/TTView.pm @ 354:9330835535b9
fixed view double rendering
author | cin |
---|---|
date | Wed, 16 Oct 2013 17:28:40 +0400 |
parents | feeb3bc4a818 |
children | 833e663796c4 |
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 { |
354 | 44 return shift->render( |
45 $layout, | |
46 hashMerge( | |
47 $args, | |
48 { | |
49 content => sub { | |
50 $ctx->invoke_environment( | |
51 sub { | |
52 return shift->display_model($model,$template,$args); | |
53 }, | |
54 { | |
55 base => $this->viewBase | |
56 } | |
57 ) | |
58 } | |
59 } | |
60 ) | |
61 ); # render | |
351
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
62 }, |
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
63 { |
353 | 64 base => $this->layoutBase, |
351
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
65 } |
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
66 ); |
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
67 } else { |
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
68 return $ctx->invoke_environment( |
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
69 sub { |
354 | 70 return shift->display_model($model,$template,$args); |
351
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
71 }, |
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
72 { |
353 | 73 base => $this->viewBase |
351
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
74 } |
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
75 ); |
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
76 } |
353 | 77 },hashMerge( |
78 { | |
79 includes => scalar($this->includes), | |
80 tt_ext => $this->tt_ext, | |
81 document => {}, | |
82 debug => sub { | |
83 warn @_; | |
84 } | |
85 }, | |
86 $this->globals | |
87 ) | |
351
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
88 ); |
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
89 } |
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
90 |
cfd7570c2af2
working on TTView: created TTView class for rendering models
cin
parents:
diff
changeset
|
91 1; |