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