annotate Lib/IMPL/Web/View/TTControl.pm @ 296:86ff93b34f2a

sync
author cin
date Tue, 05 Mar 2013 01:46:32 +0400
parents bbc0da7ef90e
children bd79145657e5
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);
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
5 use IMPL::lang qw(:hash);
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
6 use Scalar::Util qw(blessed);
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',
234
sergey
parents: 232
diff changeset
10 TTContext => 'Template::Context',
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,
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
21 name => PROP_RO,
234
sergey
parents: 232
diff changeset
22 context => PROP_RO,
sergey
parents: 232
diff changeset
23 template => PROP_RO
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 {
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
31 return $nextId++;
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
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
35 our $AutoloadRegex = qr/^[a-z]/;
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
36 our @REFLECT_META = qw(title layout);
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
37
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
38 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
39 my ($this,$name,$template,$context,$refProps) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
40
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
41 $name ||= "control";
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
42
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
43 $this->template( $template ) or die new IMPL::ArgumentException("A template is required");
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
44 $this->context( $context ) or die new IMPL::ArgumentException("A context is required");
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
45
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
46 $this->id($name . "-" . _GetNextId()) unless $this->id;
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
47
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
48 $this->name($name);
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
49 $this->attributes({});
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
50
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
51 my %attrs;
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
52
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
53 foreach my $meta ( @REFLECT_META ) {
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
54 next if $meta =~ /^_/;
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
55 if( my $value = $template->$meta() ) {
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
56 $attrs{$meta} = $value;
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
57 }
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
58 }
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
59
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
60 hashApply(\%attrs,$refProps) if ref $refProps eq 'HASH';
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
61
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
62 while (my($key,$value) = each %attrs) {
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
63 $this->SetAttribute($key,$value);
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
64 }
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
65 }
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
66
191
78a18a2b6266 IMPL::Web::View improvements (unstable)
cin
parents: 189
diff changeset
67 sub InitInstance {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
68 my ($this,$args) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
69
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
70 $args ||= {};
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
71
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
72 if ( my $ctor = $this->template->blocks->{CTOR} ) {
212
292226770180 bugfixes
sergey
parents: 194
diff changeset
73 $this->context->include($ctor, { %$args, this => $this, template => $this->template } );
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
74 }
191
78a18a2b6266 IMPL::Web::View improvements (unstable)
cin
parents: 189
diff changeset
75 }
78a18a2b6266 IMPL::Web::View improvements (unstable)
cin
parents: 189
diff changeset
76
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
77 sub GetAttribute {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
78 my ($this,$name) = (shift,shift);
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
79
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
80 if (my $method = $this->can($name)) {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
81 unshift @_,$this;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
82 goto &$method;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
83 } else {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
84 return $this->attributes->{$name};
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
85 }
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
86 }
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
87
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
88 sub SetAttribute {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
89 my $this = shift;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
90 my $name = shift;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
91
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
92 if (my $method = $this->can($name)) {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
93 unshift @_, $this;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
94 goto &$method;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
95 } else {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
96 return $this->attributes->{$name} = shift;
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
97 }
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
98 }
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
99
267
bbc0da7ef90e *IMPL::Web::View refactoring
cin
parents: 265
diff changeset
100 sub GetMainBlock {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
101 $_[0]->template->blocks->{RENDER} || $_[0]->template;
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
102 }
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
103
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
104 sub Render {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
105 my ($this,$args) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
106
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
107 $args = {} unless ref $args eq 'HASH';
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
108
267
bbc0da7ef90e *IMPL::Web::View refactoring
cin
parents: 265
diff changeset
109 if(my $body = $this->GetMainBlock ) {
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
110 return $this->context->include( $body, { %$args, this => $this, template => $this->template } );
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
111 } else {
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
112 return "";
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
113 }
185
ae8072f2f2a3 IMPL::Web::View::TTDocument tests, fixes
cin
parents: 181
diff changeset
114 }
ae8072f2f2a3 IMPL::Web::View::TTDocument tests, fixes
cin
parents: 181
diff changeset
115
267
bbc0da7ef90e *IMPL::Web::View refactoring
cin
parents: 265
diff changeset
116 sub RenderBlock {
296
cin
parents: 267
diff changeset
117 my ($this, $block, $args) = @_;
267
bbc0da7ef90e *IMPL::Web::View refactoring
cin
parents: 265
diff changeset
118
bbc0da7ef90e *IMPL::Web::View refactoring
cin
parents: 265
diff changeset
119 $args = {} unless ref $args eq 'HASH';
bbc0da7ef90e *IMPL::Web::View refactoring
cin
parents: 265
diff changeset
120
296
cin
parents: 267
diff changeset
121 return $block ? $this->context->include( $block, { %$args, this => $this, template => $this->template } ) : undef;
cin
parents: 267
diff changeset
122 }
cin
parents: 267
diff changeset
123
cin
parents: 267
diff changeset
124 sub ExportBlock {
cin
parents: 267
diff changeset
125 my ($this,$block) = @_;
cin
parents: 267
diff changeset
126
cin
parents: 267
diff changeset
127 return TemplateDocument->new({
cin
parents: 267
diff changeset
128 BLOCK => $this->template->blocks->{$block},
cin
parents: 267
diff changeset
129 DEFBLOCKS => $this->template->blocks
cin
parents: 267
diff changeset
130 });
267
bbc0da7ef90e *IMPL::Web::View refactoring
cin
parents: 265
diff changeset
131 }
bbc0da7ef90e *IMPL::Web::View refactoring
cin
parents: 265
diff changeset
132
185
ae8072f2f2a3 IMPL::Web::View::TTDocument tests, fixes
cin
parents: 181
diff changeset
133 sub AUTOLOAD {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
134 our $AUTOLOAD;
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
135
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
136 my $method = ($AUTOLOAD =~ m/(\w+)$/)[0];
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
137
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
138 return if $method eq 'DESTROY';
4d0e1962161c Replaced tabs with spaces
cin
parents: 192
diff changeset
139
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
140 if ($method =~ /$AutoloadRegex/) {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
141 my $this = shift;
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
142
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 238
diff changeset
143 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
144
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
145 return @_ ? $this->SetAttribute($method,@_) : $this->GetAttribute($method);
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
146 } else {
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
147 die OperationException->new("The specified method '$method' doesn't exists");
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
148 }
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
149 }
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
150
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
151 1;
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
152
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
153 __END__
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
154
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
155 =pod
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
156
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
157 =head1 NAME
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
158
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
159 C<IMPL::Web::View::TTControl>
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
160
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
161 =head1 SYNPOSIS
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
162
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
163 =begin text
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
164
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
165 [%
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
166 META version = 1;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
167 BLOCK INIT;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
168 # this is a document scope
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
169 dojo.require.push( 'dijit/form/Input' );
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
170 END;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
171 BLOCK CTOR;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
172 # local to this block
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
173 TPreview = require('My/Org/TextPreview');
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
174
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
175 # init control props
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
176 this.dojoClass = this.dojoClass || 'dijit.form.Input';
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
177 this.visualClass = this.visualClass || 'classic';
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
178 this.childNodes = [];
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
179
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
180 # init content
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
181 FOREACH text IN this.data;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
182 this.childNodes.push( TPreview.new('preview', nodeValue = text ) );
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
183 END;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
184
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
185 END;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
186 %]
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
187
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
188 <div class="$this.visualClass" data-dojo-type="$this.dojoClass">
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
189 [% FOREACH node IN this.childNodes %]
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
190 [% node.Render() %]
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
191 <hr />
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
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
199 Представляет собой фрагмент документа, который имеет шаблон для отображения,
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
200 набор свойств и т.п.
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
201
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
202 =head2 BLOCKS
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
203
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
204 =head3 META
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
205
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
206 Атрибуты C<META> C<layout>, C<title> будут перенесены в свойства элемента
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
207 управления.
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
208
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
209 =head3 INIT
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
210
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
211 Данный блок шаблона управления выполняется один раз при создании первого
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 подключающего C<js> модули и т.п.
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
215
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
216 Выполнение данного блока производится фабрикой элементов управления.
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
217
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
218 =head3 CTOR
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
219
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
220 данный блок выполняется каждый раз при создании нового экземпляра элемента
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
221 управления, при этом переменная C<this> указывает на эземпляр элемента
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
222 упарвления. Данный блок можно использовать для инициализации свойств элемента
213
sergey
parents: 212
diff changeset
223 управления.
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
224
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
225 =head3 RENDER
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
226
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
227 Данный блок выполняется при вызове метода C<Render()>, вывод данного блока и
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
228 есть результат отображения элемента управления. Если в шаблоне нет блока
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
229 C<RENDER>, то сам шаблон считается таковым.
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
230
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
231 =head2 TEMPLATE VARS
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
232
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
233 Каждый шаблон имеет собственное пространство имен, вложенное в пространство имен
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
234 фабрики элементов (которая разделяет пространство имен документа). В шаблоне
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 Чтобы передать данные между блоками следует использовать ссылку на элемент
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
238 управления C<this>.
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
239
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
240 =begin text
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
241
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
242 [%
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
243 BLOCK CTOR;
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
244 this.extraCssClass = 'active';
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
245 text = "this text will gone";
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
246 END;
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 <div class="$this.extraCssClass">some text $text</div>
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
250
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
251 =end text
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
252
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
253 В примере выше переменная C<$text> установленная в конструкторе шаблона, при
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
254 отображении элемента управления будет неопределена.
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
255
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
256 =over
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
257
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
258 =item * C<this>
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
259
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
260 ссылка на объект элемента управления
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
261
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
262 =item * C<component>
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
263
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
264 ссылка на текущий шаблон, устанавливается автоматически в методе
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
265 C<Template::Context::process>.
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
266
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
267 =item * C<template>
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
268
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
269 ссылка на шаблон элемента управления, для совместимости с C<TT>
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
270
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
271 =back
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
272
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
273 =head1 MEMBERS
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
274
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
275 =over
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
276
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
277 =item * C<[get]context>
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
278
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
279 Контекст элемента управления, хранит пременные шаблона. Передается в
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
280 конструкторе. Фабрика элементов управления создает новый контекст пространство
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
281 имен которого вложено в пространство имен документа.
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
282
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
283 =item * C<[get,set]template>
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
284
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
285 C<Template::Document> Шаблон элемента управления.
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
286
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
287 =item * C<AUTOLOAD>
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
288
265
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
289 Для удобства работы с шаблоном, элементы управления предоставляю доступ к своим
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
290 свойствам через метод C<AUTOLOAD>. Имена свойств должны начинаться со строчной
6b6d4b2275a1 improved documentation
cin
parents: 241
diff changeset
291 буквы.
187
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
292
927653d01f4f TTControl::AUTOLOAD now accesses nodeProperties
sergey
parents: 186
diff changeset
293 =back
181
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
294
47dac58691ee New templating system, small fixes
sourcer
parents:
diff changeset
295 =cut