annotate Lib/IMPL/Web/View/TTControl.pm @ 348:f116cd9fe7d9

working on TTView: pre-alpha version
author cin
date Thu, 03 Oct 2013 19:48:57 +0400
parents f05634287ac7
children 675cd1829255
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
1 package IMPL::Web::View::TTControl;
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
2 use strict;
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
3
234
sergey
parents: 232
diff changeset
4 use IMPL::Const qw(:prop);
334
71221d79e6b4 removing web resources contracts
cin
parents: 314
diff changeset
5 use IMPL::lang qw(:hash :base);
299
sergey
parents: 296
diff changeset
6 use Scalar::Util qw(blessed reftype);
234
sergey
parents: 232
diff changeset
7 use IMPL::declare {
sergey
parents: 232
diff changeset
8 require => {
296
cin
parents: 267
diff changeset
9 TemplateDocument => 'Template::Document',
343
9bdccdf1f50b Added a templates context
cin
parents: 342
diff changeset
10 TTContext => 'IMPL::Web::View::TTContext',
234
sergey
parents: 232
diff changeset
11 Exception => 'IMPL::Exception',
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
12 ArgumentException => '-IMPL::InvalidArgumentException',
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
13 OperationException => '-IMPL::InvalidOperationException'
234
sergey
parents: 232
diff changeset
14 },
sergey
parents: 232
diff changeset
15 base => [
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
16 'IMPL::Object' => undef
234
sergey
parents: 232
diff changeset
17 ],
sergey
parents: 232
diff changeset
18 props => [
sergey
parents: 232
diff changeset
19 id => PROP_RO,
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
20 attributes => PROP_RW,
234
sergey
parents: 232
diff changeset
21 context => PROP_RO,
346
f05634287ac7 working on the view concept
cin
parents: 343
diff changeset
22 template => PROP_RO,
f05634287ac7 working on the view concept
cin
parents: 343
diff changeset
23 parents => PROP_RO
234
sergey
parents: 232
diff changeset
24 ]
sergey
parents: 232
diff changeset
25 };
sergey
parents: 232
diff changeset
26
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
27
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
28 {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
29 my $nextId = 1;
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
30 sub _GetNextId {
299
sergey
parents: 296
diff changeset
31 return '_' . $nextId++;
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
32 }
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
33 }
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
34
300
cin
parents: 299
diff changeset
35 our $AUTOLOAD_REGEX = qr/^[a-z]/;
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
36
334
71221d79e6b4 removing web resources contracts
cin
parents: 314
diff changeset
37 my %mapSkipAttributes = map { $_, 1 } qw(attributes context);
71221d79e6b4 removing web resources contracts
cin
parents: 314
diff changeset
38
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
39 sub CTOR {
299
sergey
parents: 296
diff changeset
40 my ($this,$template,$context,$attrs) = @_;
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
41
299
sergey
parents: 296
diff changeset
42
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
43 $this->template( $template ) or die new IMPL::ArgumentException("A template is required");
334
71221d79e6b4 removing web resources contracts
cin
parents: 314
diff changeset
44
71221d79e6b4 removing web resources contracts
cin
parents: 314
diff changeset
45 die IMPL::ArgumentException->new(context => "A context is required, supplied: $context")
71221d79e6b4 removing web resources contracts
cin
parents: 314
diff changeset
46 unless is($context,TTContext);
71221d79e6b4 removing web resources contracts
cin
parents: 314
diff changeset
47
71221d79e6b4 removing web resources contracts
cin
parents: 314
diff changeset
48 $this->context( $context );
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
49
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
50 $this->attributes({});
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
51
301
aeeb57a12046 *IMPL::Web::View: templates inheritance support
cin
parents: 300
diff changeset
52 if(ref($attrs) eq 'HASH') {
299
sergey
parents: 296
diff changeset
53 while (my($key,$value) = each %$attrs) {
334
71221d79e6b4 removing web resources contracts
cin
parents: 314
diff changeset
54 next if $mapSkipAttributes{$key};
299
sergey
parents: 296
diff changeset
55 $this->SetAttribute($key,$value);
sergey
parents: 296
diff changeset
56 }
307
2da2564f115d *TTView: fixed memory leak
cin
parents: 302
diff changeset
57 }
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
58
299
sergey
parents: 296
diff changeset
59 $this->id(_GetNextId()) unless $this->id;
191
78a18a2b6266 IMPL::Web::View improvements (unstable)
cin
parents: 189
diff changeset
60 }
78a18a2b6266 IMPL::Web::View improvements (unstable)
cin
parents: 189
diff changeset
61
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
62 sub GetAttribute {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
63 my ($this,$name) = (shift,shift);
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
64
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
65 if (my $method = $this->can($name)) {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
66 unshift @_,$this;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
67 goto &$method;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
68 } else {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
69 return $this->attributes->{$name};
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
70 }
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
71 }
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
72
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
73 sub SetAttribute {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
74 my $this = shift;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
75 my $name = shift;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
76
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
77 if (my $method = $this->can($name)) {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
78 unshift @_, $this;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
79 goto &$method;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
80 } else {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
81 return $this->attributes->{$name} = shift;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
82 }
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
83 }
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
84
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
85 sub Render {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
86 my ($this,$args) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
87
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
88 $args = {} unless ref $args eq 'HASH';
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
89
299
sergey
parents: 296
diff changeset
90 return $this->context->include(
301
aeeb57a12046 *IMPL::Web::View: templates inheritance support
cin
parents: 300
diff changeset
91 $this->template->block,
299
sergey
parents: 296
diff changeset
92 {
sergey
parents: 296
diff changeset
93 %$args,
sergey
parents: 296
diff changeset
94 this => $this,
sergey
parents: 296
diff changeset
95 template => $this->template
sergey
parents: 296
diff changeset
96 }
sergey
parents: 296
diff changeset
97 );
267
bbc0da7ef90e *IMPL::Web::View refactoring
cin
parents: 265
diff changeset
98 }
bbc0da7ef90e *IMPL::Web::View refactoring
cin
parents: 265
diff changeset
99
302
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
100 sub GetTemplate {
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
101 my ($this,$name) = @_;
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
102
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
103 return eval { $this->context->template($name) };
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
104 }
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
105
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
106 sub Include {
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
107 my ($this,$template, $args) = @_;
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
108
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
109 my $tpl = $this->GetTemplate($template)
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
110 or die OperationException->new("The specified template isn't found", $template);
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
111
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
112 return $this->context->include(
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
113 $tpl,
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
114 $args
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
115 );
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
116 }
673581380e79 Added templates provider functionality to controls
cin
parents: 301
diff changeset
117
314
cin
parents: 307
diff changeset
118 sub HasBlock {
cin
parents: 307
diff changeset
119 my ($this,$block) = @_;
cin
parents: 307
diff changeset
120
cin
parents: 307
diff changeset
121 $this->GetTemplate ? 1 : 0;
cin
parents: 307
diff changeset
122 }
cin
parents: 307
diff changeset
123
185
ae8072f2f2a3 IMPL::Web::View::TTDocument tests, fixes
cin
parents: 181
diff changeset
124 sub AUTOLOAD {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
125 our $AUTOLOAD;
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
126
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
127 my $method = ($AUTOLOAD =~ m/(\w+)$/)[0];
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
128
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
129 return if $method eq 'DESTROY';
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
130
300
cin
parents: 299
diff changeset
131 if ($method =~ /$AUTOLOAD_REGEX/) {
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
132 my $this = shift;
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
133
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
134 die OperationException->new("can't invoke method '$method' on an unblessed reference") unless blessed $this;
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
135
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
136 return @_ ? $this->SetAttribute($method,@_) : $this->GetAttribute($method);
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
137 } else {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
138 die OperationException->new("The specified method '$method' doesn't exists");
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
139 }
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
140 }
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
141
342
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
142 sub CreateControlFromTemplate {
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
143 my ($this,$template,$args) = @_;
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
144
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
145 if (not ref($template)) {
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
146 return $this->context->stash->get([
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
147 require => [
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
148 $template
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
149 ]
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
150 ])->new($args);
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
151 } else {
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
152 return $this->new(
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
153 $template,
343
9bdccdf1f50b Added a templates context
cin
parents: 342
diff changeset
154 $this->context->clone(),
342
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
155 $args
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
156 );
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
157 }
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
158 }
1090c1dd7429 TTControl: added a helper method 'CreateControlFromTemlpate'
cin
parents: 334
diff changeset
159
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
160 1;
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
161
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
162 __END__
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
163
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
164 =pod
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
165
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
166 =head1 NAME
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
167
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
168 C<IMPL::Web::View::TTControl>
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
169
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
170 =head1 SYNPOSIS
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
171
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
172 =begin text
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
173
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
174 [%
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
175 META version = 1;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
176 BLOCK INIT;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
177 # this is a document scope
299
sergey
parents: 296
diff changeset
178 dojo.modules.push( 'dijit/form/Input' );
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
179 END;
299
sergey
parents: 296
diff changeset
180
sergey
parents: 296
diff changeset
181 # local to this block
sergey
parents: 296
diff changeset
182 TPreview = require('My/Org/TextPreview');
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
183
299
sergey
parents: 296
diff changeset
184 # init control props
sergey
parents: 296
diff changeset
185 visualClass = this.visualClass || 'classic';
sergey
parents: 296
diff changeset
186 %]
sergey
parents: 296
diff changeset
187 <div id="$id" class="$visualClass" data-dojo-type="dijit/form/Input">
sergey
parents: 296
diff changeset
188 [% FOREACH item IN model %]
sergey
parents: 296
diff changeset
189 <div class="itemContainer">
sergey
parents: 296
diff changeset
190 [% Display(item) %]
sergey
parents: 296
diff changeset
191 </div>
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
192 [% END %]
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
193 </div>
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
194
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
195 =end text
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
196
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
197 =head1 DESCRIPTION
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
198
299
sergey
parents: 296
diff changeset
199 Легкая обертка вокруг шаблона, позволяет изолировать пространство имен шаблона,
sergey
parents: 296
diff changeset
200 а также реализовать собственные методы по представлению данных (в случае если
sergey
parents: 296
diff changeset
201 это проще сделать в виде методов класса).
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
202
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
203 =head2 BLOCKS
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
204
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
205 =head3 META
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
206
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
207 Атрибуты C<META> C<layout>, C<title> будут перенесены в свойства элемента
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
208 управления.
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
209
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
210 =head3 INIT
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
211
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
212 Данный блок шаблона управления выполняется один раз при создании первого
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
213 экземпляра элемента управления, в пространстве имен документа. Может
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
214 использоваться для формирования заголовочной части документа, скрипта
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
215 подключающего C<js> модули и т.п.
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
216
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
217 Выполнение данного блока производится фабрикой элементов управления.
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
218
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
219 =head2 TEMPLATE VARS
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
220
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
221 Каждый шаблон имеет собственное пространство имен, вложенное в пространство имен
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
222 фабрики элементов (которая разделяет пространство имен документа). В шаблоне
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
223 могут определяться новые переменные, однако они останутся локальными для блоков.
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
224
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
225 Чтобы передать данные между блоками следует использовать ссылку на элемент
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
226 управления C<this>.
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
227
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
228 =begin text
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
229
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
230 [%
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
231 BLOCK CTOR;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
232 this.extraCssClass = 'active';
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
233 text = "this text will gone";
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
234 END;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
235 %]
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
236
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
237 <div class="$this.extraCssClass">some text $text</div>
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
238
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
239 =end text
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
240
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
241 В примере выше переменная C<$text> установленная в конструкторе шаблона, при
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
242 отображении элемента управления будет неопределена.
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
243
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
244 =over
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
245
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
246 =item * C<this>
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
247
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
248 ссылка на объект элемента управления
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
249
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
250 =item * C<component>
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
251
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
252 ссылка на текущий шаблон, устанавливается автоматически в методе
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
253 C<Template::Context::process>.
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
254
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
255 =item * C<template>
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
256
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
257 ссылка на шаблон элемента управления, для совместимости с C<TT>
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
258
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
259 =back
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
260
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
261 =head1 MEMBERS
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
262
300
cin
parents: 299
diff changeset
263 =head2 C<[get]context>
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
264
300
cin
parents: 299
diff changeset
265 Контекст элемента управления, хранит пременные шаблона. Фабрика элементов
cin
parents: 299
diff changeset
266 управления создает новый контекст пространство имен которого вложено в
cin
parents: 299
diff changeset
267 пространство имен документа.
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
268
300
cin
parents: 299
diff changeset
269 Контекст следует использовать только при рендеринге документа.
cin
parents: 299
diff changeset
270
cin
parents: 299
diff changeset
271 =head2 C<[get,set]template>
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
272
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
273 C<Template::Document> Шаблон элемента управления.
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
274
300
cin
parents: 299
diff changeset
275 =head2 C<AUTOLOAD>
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
276
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
277 Для удобства работы с шаблоном, элементы управления предоставляю доступ к своим
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
278 свойствам через метод C<AUTOLOAD>. Имена свойств должны начинаться со строчной
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
279 буквы.
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
280
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
281 =cut