Mercurial > pub > Impl
comparison Lib/IMPL/Web/TT/Document.pm @ 146:60fd224f3e3c
fixed cgi parameters processing
Added parameters inflating feature
Added preprocessed templates, reformatting output
author | wizard |
---|---|
date | Mon, 26 Jul 2010 03:19:06 +0400 |
parents | bd10093bb122 |
children | 4369d5458bb6 |
comparison
equal
deleted
inserted
replaced
145:bd10093bb122 | 146:60fd224f3e3c |
---|---|
16 private property _provider => prop_all; | 16 private property _provider => prop_all; |
17 private property _context => prop_all; | 17 private property _context => prop_all; |
18 public property cache => prop_all; | 18 public property cache => prop_all; |
19 public property template => prop_get | owner_set; | 19 public property template => prop_get | owner_set; |
20 public property presenter => prop_all, { validate => \&_validatePresenter }; | 20 public property presenter => prop_all, { validate => \&_validatePresenter }; |
21 public property preprocess => prop_all | prop_list, | |
21 private property _controlClassMap => prop_all; | 22 private property _controlClassMap => prop_all; |
22 } | 23 } |
23 | 24 |
24 our %CTOR = ( | 25 our %CTOR = ( |
25 'IMPL::DOM::Document' => sub { nodeName => 'document' } | 26 'IMPL::DOM::Document' => sub { nodeName => 'document' } |
31 $this->_controlClassMap({}); | 32 $this->_controlClassMap({}); |
32 $this->registerControlClass( Control => 'IMPL::Web::TT::Control' ); | 33 $this->registerControlClass( Control => 'IMPL::Web::TT::Control' ); |
33 $this->appendChild( $this->Create(body => 'IMPL::Web::TT::Collection') ); | 34 $this->appendChild( $this->Create(body => 'IMPL::Web::TT::Collection') ); |
34 $this->appendChild( $this->Create(head => 'IMPL::Web::TT::Collection') ); | 35 $this->appendChild( $this->Create(head => 'IMPL::Web::TT::Collection') ); |
35 $this->cache($args{cache}) if $args{cache}; | 36 $this->cache($args{cache}) if $args{cache}; |
37 $this->preprocess($args{preprocess}) if $args{preprocess}; | |
36 } | 38 } |
37 | 39 |
38 sub CreateControl { | 40 sub CreateControl { |
39 my ($this,$name,$class,$args) = @_; | 41 my ($this,$name,$class,$args) = @_; |
40 | 42 |
75 this => $this, | 77 this => $this, |
76 render => sub { | 78 render => sub { |
77 $this->_process(@_); | 79 $this->_process(@_); |
78 } | 80 } |
79 }, | 81 }, |
80 POST_CHOMP => 2, | |
81 PRE_CHOMP => 2, | |
82 RECURSION => 1, | 82 RECURSION => 1, |
83 LOAD_TEMPLATES => [$this->provider] | 83 LOAD_TEMPLATES => [$this->provider] |
84 ) | 84 ) |
85 ) | 85 ) |
86 } | 86 } |
101 | 101 |
102 eval "require $type; 1;" or die new IMPL::Exception("Failed to load a module",$type,"$@") unless eval { $type->can('new') }; | 102 eval "require $type; 1;" or die new IMPL::Exception("Failed to load a module",$type,"$@") unless eval { $type->can('new') }; |
103 | 103 |
104 die new IMPL::InvalidArgumentException("A type must be subclass of IMPL::DOM::Node",$type) unless $type->isa('IMPL::DOM::Node'); | 104 die new IMPL::InvalidArgumentException("A type must be subclass of IMPL::DOM::Node",$type) unless $type->isa('IMPL::DOM::Node'); |
105 | 105 |
106 # resolve template name to a real template | |
107 $args->{template} = $this->context->template($args->{template}) if $args->{template}; | |
108 | |
106 $this->_controlClassMap->{$controlClass} = { | 109 $this->_controlClassMap->{$controlClass} = { |
107 controlClass => $controlClass, | 110 controlClass => $controlClass, |
108 type => $type, | 111 type => $type, |
109 args => ref $args eq 'HASH' ? $args : {} | 112 args => ref $args eq 'HASH' ? $args : {} |
110 }; | 113 }; |
125 die new IMPL::InvalidOperationException("A specified template isn't a control",$template) unless $controlClass; | 128 die new IMPL::InvalidOperationException("A specified template isn't a control",$template) unless $controlClass; |
126 | 129 |
127 if (not $this->isControlClass($controlClass)) { | 130 if (not $this->isControlClass($controlClass)) { |
128 if ($doc->template) { | 131 if ($doc->template) { |
129 $controlTemplate = $doc->blocks()->{$doc->template} || $this->context->template($doc->template); | 132 $controlTemplate = $doc->blocks()->{$doc->template} || $this->context->template($doc->template); |
130 $out = $this->context->process($doc); | 133 $out = $this->context->include($doc); |
131 } else { | 134 } else { |
132 $controlTemplate = $doc; | 135 $controlTemplate = $doc; |
133 } | 136 } |
134 $this->registerControlClass($controlClass,$type,{ template => $controlTemplate } ); | 137 $this->registerControlClass($controlClass,$type,{ template => $controlTemplate } ); |
135 } | 138 } |
172 $this->provider( | 175 $this->provider( |
173 ENCODING => $encoding, | 176 ENCODING => $encoding, |
174 INTERPOLATE => 1, | 177 INTERPOLATE => 1, |
175 PRE_CHOMP => 1, | 178 PRE_CHOMP => 1, |
176 POST_CHOMP => 1, | 179 POST_CHOMP => 1, |
180 TRIM => 0, | |
177 COMPILE_EXT => $this->cache ? '.ttc' : undef, | 181 COMPILE_EXT => $this->cache ? '.ttc' : undef, |
178 COMPILE_DIR => $this->cache, | 182 COMPILE_DIR => $this->cache, |
179 INCLUDE_PATH => [$inc,@includes] | 183 INCLUDE_PATH => [$inc,@includes] |
180 ); | 184 ); |
185 | |
186 $this->context->process($_) foreach $this->preprocess; | |
181 | 187 |
182 $this->template($this->context->template($fileName)); | 188 $this->template($this->context->template($fileName)); |
183 } | 189 } |
184 | 190 |
185 sub AddVar { | 191 sub AddVar { |