annotate Lib/IMPL/Web/View/TTView.pm @ 351:cfd7570c2af2

working on TTView: created TTView class for rendering models
author cin
date Tue, 08 Oct 2013 17:40:35 +0400
parents
children feeb3bc4a818
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
4 use IMPL::Const qw(:prop);
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
5 use IMPL::declare {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
6 require => {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
7 Context => 'IMPL::Web::View::TTContext'
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
8 },
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
9 base => [
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
10 'IMPL::Object' => undef,
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
11 'IMPL::Object::Autofill' => '@_',
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
12 'IMPL::Object::Serializable' => undef
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
13 ],
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
14 props => [
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
15 options => PROP_RW,
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
16 view => PROP_RW,
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
17 layout => PROP_RW,
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
18 tt_ext => PROP_RW,
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
19 includes => PROP_RW | PROP_LIST
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
20 ]
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
21 };
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
22
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
23 sub CTOR {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
24 my ($this) = @_;
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 $this->tt_ext('tt') unless defined $this->tt_ext;
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
27 }
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 sub display {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
30 my ($this,$model,$template,$args) = @_;
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 my $context = Context->new($this->options);
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
33 my $layout = delete $args->{layout};
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 return $context->invoke_environment(
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
36 sub {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
37 my $ctx = shift;
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
38 if ($layout) {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
39 return $ctx->invoke_environment(
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
40 sub {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
41 return $ctx->render($layout,$args);
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
42 },
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
43 {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
44 base => $this->layout,
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
45 content => sub {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
46 $ctx->invoke_environment(
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
47 sub {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
48 return shift->display($model,$template,$args);
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
49 },
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
50 {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
51 base => $this->view
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 )
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
54 }
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 } else {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
58 return $ctx->invoke_environment(
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
59 sub {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
60 return $ctx->display($model,$template,$args);
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
61 },
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 base => $this->view
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 );
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 },{
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
68 includes => scalar($this->includes),
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
69 tt_ext => 'tt',
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
70 document => {},
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
71 debug => sub {
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
72 warn @_;
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
73 }
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 }
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
77
cfd7570c2af2 working on TTView: created TTView class for rendering models
cin
parents:
diff changeset
78 1;