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