Mercurial > pub > Impl
annotate Lib/IMPL/Web/View/TTDocument.pm @ 288:3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
author | sergey |
---|---|
date | Tue, 19 Feb 2013 19:58:27 +0400 |
parents | 2d253e6e4a88 |
children | 85572f512abc |
rev | line source |
---|---|
181 | 1 package IMPL::Web::View::TTDocument; |
2 use strict; | |
3 | |
236 | 4 use Scalar::Util qw(weaken); |
5 use IMPL::Const qw(:prop); | |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
6 use IMPL::lang qw(:hash is); |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
7 use Carp qw(carp); |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
8 use mro; |
181 | 9 |
236 | 10 use IMPL::declare { |
11 require => { | |
12 TTFactory => 'IMPL::Web::View::TTFactory', | |
13 TTControl => 'IMPL::Web::View::TTControl', | |
14 Loader => 'IMPL::Code::Loader' | |
15 }, | |
16 base => [ | |
17 'IMPL::Web::View::TTControl' => sub { | |
287 | 18 my ($template,$ctx) = @_; |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
19 $ctx ||= Template::Context->new(); |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
20 return 'document', $template, $ctx; # context |
236 | 21 } |
22 ], | |
23 props => [ | |
24 layout => PROP_RW, | |
25 loader => PROP_RW, | |
26 controls => PROP_RO, | |
27 ] | |
28 }; | |
181 | 29 |
30 sub CTOR { | |
287 | 31 my ($this,$template,$ctx,$loader,$vars) = @_; |
194 | 32 |
33 $this->controls({}); | |
34 $this->loader($loader) if $loader; | |
35 | |
36 $this->layout( $template->layout ) unless $this->layout; | |
37 | |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
38 $this->context->stash->update($vars) |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
39 if ref $vars eq 'HASH'; |
194 | 40 |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
41 $this->InitInstance(); |
181 | 42 } |
43 | |
189 | 44 sub templateVars { |
194 | 45 my $this = shift; |
46 my $name = shift; | |
47 if (@_) { | |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
48 return $this->context->stash->set($name, shift); |
194 | 49 } else { |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
50 return $this->context->stash->get($name); |
194 | 51 } |
189 | 52 } |
53 | |
236 | 54 sub RequireControl { |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
55 my ($this, $control, $ctx) = @_; |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
56 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
57 $ctx ||= $this->context; |
194 | 58 |
59 if (my $factory = $this->controls->{$control}) { | |
60 return $factory; | |
61 } else { | |
62 my $path = $control; | |
267 | 63 |
194 | 64 if ( my $template = $this->loader->template($path) ) { |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
65 |
194 | 66 $factory = new IMPL::Web::View::TTFactory( |
263 | 67 $template->class || TTControl, |
194 | 68 $template, |
69 $ctx, | |
267 | 70 join( '/', splice( @{[split(/\//,$path)]}, 0, -1 ) ) |
194 | 71 ); |
72 | |
236 | 73 if ($template->class) { |
74 Loader->safe->Require($template->class); | |
75 } | |
76 | |
194 | 77 $this->controls->{$control} = $factory; |
78 | |
79 return $factory; | |
188 | 80 |
194 | 81 } else { |
82 die new IMPL::KeyNotFoundException($control); | |
83 } | |
84 } | |
181 | 85 } |
86 | |
87 sub Render { | |
194 | 88 my ($this,$args) = @_; |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
89 |
241
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
238
diff
changeset
|
90 $args ||= {}; |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
91 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
92 $this->context->localise(); |
241
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
238
diff
changeset
|
93 |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
94 my $documentContext; |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
95 my %controls; |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
96 my $require; |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
97 $require = sub { |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
98 my $control = shift; |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
99 if (my $factory = $controls{$control}) { |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
100 return $factory; |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
101 } else { |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
102 my $path = $control; |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
103 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
104 if ( my $template = $this->loader->template($path) ) { |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
105 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
106 $factory = new IMPL::Web::View::TTFactory( |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
107 $template->class || TTControl, |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
108 $template, |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
109 $documentContext, |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
110 join( '/', splice( @{[split(/\//,$path)]}, 0, -1 ) ), |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
111 $require |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
112 ); |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
113 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
114 if ($template->class) { |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
115 Loader->safe->Require($template->class); |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
116 } |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
117 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
118 $controls{$control} = $factory; |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
119 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
120 return $factory; |
194 | 121 |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
122 } else { |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
123 die new IMPL::KeyNotFoundException($control); |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
124 } |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
125 } |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
126 }; |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
127 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
128 $this->context->stash->set(require => $require); |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
129 $this->context->stash->set(document => $this); |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
130 $documentContext = Template::Context->new( { %{$this->context} } ); |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
131 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
132 my $text = eval { |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
133 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
134 if ($this->layout) { |
287 | 135 my $tlayout = $this->loader->layout($this->layout); |
136 if(my $init = $tlayout->blocks->{INIT}) { | |
137 $this->context->process( | |
138 $init, | |
139 hashMerge( | |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
140 $args, |
287 | 141 { |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
142 template => $this->template |
287 | 143 } |
144 ) | |
145 ); | |
146 } | |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
147 my $content = $this->next::method($args); |
287 | 148 return $this->context->include( |
149 $tlayout, | |
150 { | |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
151 %{$args}, |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
152 content => $content, |
287 | 153 this => $this, |
154 template => $this->template | |
155 } | |
286 | 156 ); |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
157 } else { |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
158 return $this->next::method($args); |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
159 } |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
160 }; |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
161 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
162 $this->context->delocalise(); |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
163 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
164 my $e = $@; |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
165 if ($e) { |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
166 die $e; |
194 | 167 } else { |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
168 return $text; |
194 | 169 } |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
170 |
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
171 |
190
cd1ff7029a63
IMLP::Web::View refactored, added new method 'require' which is available inside templates. Changed document rendering.
cin
parents:
189
diff
changeset
|
172 } |
cd1ff7029a63
IMLP::Web::View refactored, added new method 'require' which is available inside templates. Changed document rendering.
cin
parents:
189
diff
changeset
|
173 |
181 | 174 1; |
175 | |
176 __END__ | |
177 | |
178 =pod | |
179 | |
180 =head1 NAME | |
181 | |
182 C<IMPL::Web::View::TTDocument> - документ для построения HTML страницы на основе шаблонов TT. | |
183 | |
184 =head1 SYNOPSIS | |
185 | |
186 =begin code | |
187 | |
188 use IMPL::Web::View::TTDocument(); | |
189 | |
190 my $doc = new IMPL::Wbe::View::TTDocument($template,$ttOptions); | |
191 | |
192 return $doc->Render(); | |
193 | |
194 =end code | |
195 | |
196 Однако, более предпочтительный способ использовать C<IMPL::Web::View::TTLoader>. | |
197 | |
198 =head1 DESCRIPTION | |
199 | |
200 Документ для представления данных. Документы представляют собой иерархически организованные данные, | |
201 элементами данного документа являются данные для отображения, такие как | |
202 | |
203 =over | |
204 | |
205 =item * Объекты из БД | |
206 | |
207 =item * Навигационные цепочки | |
208 | |
209 =item * Меню и т.п. | |
210 | |
211 =back | |
212 | |
213 Скприт шаблона формирует структуру документа, затем сформированная структура форматируется в готовый документ. | |
192 | 214 Процесс форматирования объектной модели в готовый документ может быть выполнена как вручную, так и при помощи |
189 | 215 вспомогательного шаблона - обертки. Если у шаблона документа указан C<layout> в метаданных, то он будет |
181 | 216 использован как шаблон для форматирования объектной модели, вывод самого шаблона будет проигнорирован. Если |
217 обертка не задана, то результатом будет вывод самого скрипта шаблона. | |
218 | |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
219 Использование объектной модели документа позволяет решить задачи по созданию контейнеров, |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
220 у которых может быть сложное содежимое. Примером таких элементов могут быть формы, |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
221 внутри форм элементы управления также могут группироваться. |
192 | 222 |
193 | 223 =head2 Элементы управления (компоненты) |
224 | |
225 Документ состоит из узлов, часть которых наследуется от C<IMPL::Web::View::TTControl>, такие узлы называются | |
226 элементами управления. Каждый элемент управления имеет собственный контекст, который наследуется от контекста | |
227 документа. | |
228 | |
229 =head2 Фабрика элементов управления | |
230 | |
231 Для создания элементов управления используются фабрики. Каждый элемен управления имеет свой шаблон для | |
232 форматиорвания содержимого, фабрика связывает шаблон и класс элемента управления, для чего при загрузке | |
233 шаблона используется свойство C<type> из метаданных. Фабрика загружается в документ при том только один | |
234 раз, повторные загрузки фабрики возвращают уже загруженную. Для загрузки фабрики используется метод | |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
235 C<require()> с указанием элемента управления. |
190
cd1ff7029a63
IMLP::Web::View refactored, added new method 'require' which is available inside templates. Changed document rendering.
cin
parents:
189
diff
changeset
|
236 |
185 | 237 =head2 Порядок обработки документа |
238 | |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
239 Построение представления данных состоит из двух этапов |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
240 |
185 | 241 =over |
242 | |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
243 =item 1 Создание объектной модели документа. На данном этапе создаются все элементы управления. |
185 | 244 |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
245 =item 1 Преобразование объектной модели в конечнное представление. На данном этапе происходит |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
246 форматирование документа. |
185 | 247 |
248 =back | |
181 | 249 |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
250 |
181 | 251 =head2 Загрузка элемента управления |
252 | |
253 =over | |
254 | |
194 | 255 =item 1 C<TInput = require('my/org/input')> |
181 | 256 |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
257 =item 1 Загружается шаблон C<my/org/input.tt> |
181 | 258 |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
259 =item 1 Создается фабрика элементов управления с собственным контекстом, унаследованным от контекст документа. |
181 | 260 |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
261 =item 1 При первом создании элемента управления фабрика инициализируется выполнением блока C<INIT>. |
181 | 262 |
263 =back | |
264 | |
265 =head2 Создание элемента управления | |
266 | |
267 =over | |
268 | |
194 | 269 =item 1 C<< TInput.new('login') >> |
181 | 270 |
271 =item 1 Создается новый дочерний контекст к контексту фабрики | |
272 | |
273 =item 1 Создается экземпляр элемента управления | |
274 | |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
275 =item 1 Выполняется блок конструктора C<CTOR> в контексте элемента управления, параметр C<this> имеет значение |
181 | 276 нового экземпляра элемента управления |
277 | |
278 =back | |
279 | |
280 =head1 MEMBERS | |
281 | |
282 =over | |
283 | |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
284 =item C<CTOR($template, $contextOpts, $loader[, $vars])> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
285 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
286 Создает экземпляр документа с указанным шаблоном и параметрами. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
287 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
288 =over |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
289 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
290 =item C<$template> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
291 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
292 C<Template::Document> шаблон документа. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
293 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
294 =item C<$contextOpts> |
181 | 295 |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
296 C<HASH> Параметры контекста C<Template::Context> для документа. Эти параметры будут сохранены |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
297 в свойстве C<opts>, а также на их основе будет создан контекст текщего документа. Как правило |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
298 эти параметы задаются загрузчиком документа C<IMPL::Web::View::TTLoader>, таким образом, что |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
299 C<Template::Stash> создаваемого контекста наследует переменные из контекста загрузчика. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
300 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
301 =item C<$loader> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
302 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
303 C<IMPL::Web::View::TTLoader> загрузчик, который будет использоваться для загрузки элементов управления, |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
304 а также для получения обертки, заданной в свойстве документа C<layout>. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
305 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
306 =item C<$vars> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
307 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
308 C<HASH> Необязательный параметр. переменные которые будут переданы в блок конструктора C<INIT>. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
309 Как правило они используются для передачи данных для построения документа |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
310 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
311 =back |
181 | 312 |
313 =back | |
314 | |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
315 =over |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
316 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
317 =item C<templateVars($name[,$newValue])> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
318 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
319 Получает или задает переменную для шаблона документа. Имя переменнной может быть составным, |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
320 например C<'my.var.name'>, см. C<Template::Stash::set()>. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
321 |
236 | 322 =item C<RequireControl($controlName)> |
195
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
323 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
324 Загружает фабрику элемента управления, если она уже была загружена, возвращает на нее ссылку. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
325 При загрузки фабрики для нее создается собственный контекст на основе параметров из свойства |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
326 C<opts> и ее пространство имен наследуется от пространства имен документа из свойства C<stash>. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
327 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
328 =item C<Render($vars)> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
329 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
330 Выполняет блок C<renderBlock> документа для получения конечного представления, C<$vars> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
331 содержит переменные для блока. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
332 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
333 =item C<RenderContent($vars)> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
334 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
335 Выполняет шаблон документа для получения представления содержимого, в отличии от |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
336 метода C<Render> не использует обертку указанную в свойстве C<layout>, если обертка |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
337 не указана, то эти методы идентичны. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
338 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
339 =item C<[get,set]layout> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
340 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
341 Обертка, которая будет использована для построения представления документа. В обертке |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
342 будет доступна специальная переменная C<content>, при обращении к которой будет B<выполнен> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
343 метод C<RenderContent()> и возвращен результат его работы. Для получения шаблона обертки |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
344 используется загрузчик из свойства C<loader>. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
345 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
346 =item C<[get]opts> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
347 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
348 Параметры контекста, используются для создания контекстов фабрик элементов управления. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
349 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
350 =item C<[get]loader> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
351 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
352 Загрузчик, используется для загрузки шаблонов фабрик элементов управления и обертки. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
353 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
354 =item C<[get]controls> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
355 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
356 C<HASH> Коллекция загруженных фабрик элементов управления, ключем является |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
357 квалифицированное имя элемента управления. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
358 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
359 =item C<[get]stash> |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
360 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
361 C<Template::Stash> Пространство имен документа, оно используется как родительское |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
362 для пространств имен загружаемых фабрик элементов управления. |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
363 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
364 =back |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
365 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
366 =head1 TEMPLATES |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
367 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
368 =begin text |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
369 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
370 [%META layout='default'%] |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
371 [% BLOCK CTOR; |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
372 section('top','TOP'); |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
373 section('bottom','BOTTOM'); |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
374 section('client','CLIENT'); |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
375 END %] |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
376 [% BLOCK TOP; |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
377 TMenu = require('my/org/Menu'); |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
378 append(TMenu.new()); |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
379 END %] |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
380 |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
381 =end |
7a920771fd8e
IMPL::Web::View changed document layout handling, docs, examples
cin
parents:
194
diff
changeset
|
382 |
181 | 383 =cut |