annotate Lib/IMPL/Web/View/TTView.pm @ 358:248f95c1762a

added simple XML Sax parser
author sergey
date Mon, 18 Nov 2013 01:25:35 +0400
parents 9330835535b9
children 833e663796c4
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 {
354
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
44 return shift->render(
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
45 $layout,
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
46 hashMerge(
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
47 $args,
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
48 {
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
49 content => sub {
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
50 $ctx->invoke_environment(
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
51 sub {
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
52 return shift->display_model($model,$template,$args);
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
53 },
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
54 {
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
55 base => $this->viewBase
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
56 }
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
57 )
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
58 }
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
59 }
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
60 )
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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
9330835535b9 fixed view double rendering
cin
parents: 353
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
77 },hashMerge(
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 includes => scalar($this->includes),
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
80 tt_ext => $this->tt_ext,
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
81 document => {},
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
82 debug => sub {
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
83 warn @_;
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
84 }
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
85 },
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
86 $this->globals
feeb3bc4a818 corrected error handling while loading templates
cin
parents: 351
diff changeset
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;