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
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
353
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
17 viewBase => PROP_RW,
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
21 includes => PROP_RW | PROP_LIST,
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
70 },hashMerge(
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
71 {
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
72 includes => scalar($this->includes),
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
73 tt_ext => $this->tt_ext,
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
74 document => {},
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
75 debug => sub {
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
76 warn @_;
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
77 }
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
78 },
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
79 $this->globals
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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;