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

working on TTView: pre-alpha version
author cin
date Thu, 03 Oct 2013 19:48:57 +0400
parents 3eafa6fefa9f
children 86b470004d47
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
343
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
1 package IMPL::Web::View::TTContext;
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
2 use strict;
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
3 use Template::Base;
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
4 use Carp qw(carp);
343
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
5
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
6 use IMPL::Exception();
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
7 use IMPL::lang qw(is typeof hashApply);
343
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
8 use IMPL::declare {
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
9 require => {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
10 Document => '-Template::Document',
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
11 TypeKeyedCollection => 'IMPL::TypeKeyedCollection',
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
12 ArgException => "-IMPL::InvalidArgumentException"
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
13 },
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
14 base => [
343
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
15 'Template::Context' => '@_'
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
16 ]
343
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
17 };
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
18
347
cin
parents: 346
diff changeset
19 BEGIN {
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
20 no strict 'refs';
347
cin
parents: 346
diff changeset
21 foreach my $prop (qw(
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
22 root
347
cin
parents: 346
diff changeset
23 base
cin
parents: 346
diff changeset
24 tt_ext
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
25 tt_cache
347
cin
parents: 346
diff changeset
26 parent
cin
parents: 346
diff changeset
27 prefix
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
28 cache
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
29 includes
347
cin
parents: 346
diff changeset
30 )) {
cin
parents: 346
diff changeset
31 my $t = $prop;
cin
parents: 346
diff changeset
32
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
33 *{__PACKAGE__ . '::' . $prop} = sub {
347
cin
parents: 346
diff changeset
34 my $this = shift;
cin
parents: 346
diff changeset
35 return @_ ? $this->stash->set($t, @_) : $this->stash->get($t);
cin
parents: 346
diff changeset
36 }
cin
parents: 346
diff changeset
37 }
cin
parents: 346
diff changeset
38 }
cin
parents: 346
diff changeset
39
343
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
40 sub clone {
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
41 my $this = shift;
347
cin
parents: 346
diff changeset
42 my $params = shift;
343
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
43
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
44 $this->localise();
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
45
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
46 my $args = { %{$this} };
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
47
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
48 $this->delocalise();
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
49
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
50 my $class = ref($this);
343
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
51
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
52 delete $args->{CONFIG};
9bdccdf1f50b Added a templates context
cin
parents:
diff changeset
53
347
cin
parents: 346
diff changeset
54 my $clone = $class->new($args);
cin
parents: 346
diff changeset
55
cin
parents: 346
diff changeset
56 $clone->stash->update($params) if $params;
cin
parents: 346
diff changeset
57
cin
parents: 346
diff changeset
58 return $clone;
345
cin
parents: 343
diff changeset
59 }
cin
parents: 343
diff changeset
60
cin
parents: 343
diff changeset
61 sub find_template {
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
62 my ($this,$name) = @_;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
63
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
64 my $cache = $this->tt_cache;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
65 $this->tt_cache($cache = {}) unless $cache;
345
cin
parents: 343
diff changeset
66
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
67 if(my $tpl = $cache->{$name}) {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
68 return $tpl;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
69 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
70
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
71 my @inc = ($this->base, @{$this->includes || []});
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
72
345
cin
parents: 343
diff changeset
73 my $ext = $this->tt_ext || "";
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
74
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
75 my $file;
345
cin
parents: 343
diff changeset
76
cin
parents: 343
diff changeset
77 foreach my $dir (@inc) {
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
78 $file = $dir ? "$dir/$name" : $name;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
79
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
80 my $base = join('/',splice([split(/\/+/,$file)],0,-1));
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
81
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
82 $file = $ext ? "$file.$ext" : $file;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
83
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
84 warn "lookup: $file";
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
85
345
cin
parents: 343
diff changeset
86 my $tt = eval { $this->template($file) };
cin
parents: 343
diff changeset
87
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
88 return $cache->{$name} = {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
89 base => $base,
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
90 template => $tt,
345
cin
parents: 343
diff changeset
91 } if $tt;
cin
parents: 343
diff changeset
92 }
cin
parents: 343
diff changeset
93
cin
parents: 343
diff changeset
94 $this->throw(Template::Constants::ERROR_FILE, "$name: not found");
cin
parents: 343
diff changeset
95 }
cin
parents: 343
diff changeset
96
347
cin
parents: 346
diff changeset
97 sub display {
cin
parents: 346
diff changeset
98 my $this = shift;
cin
parents: 346
diff changeset
99 my $model = shift;
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
100 my ($template, $args);
347
cin
parents: 346
diff changeset
101
cin
parents: 346
diff changeset
102 if (ref $_[0] eq 'HASH') {
cin
parents: 346
diff changeset
103 $args = shift;
cin
parents: 346
diff changeset
104 } else {
cin
parents: 346
diff changeset
105 $template = shift;
cin
parents: 346
diff changeset
106 $args = shift;
cin
parents: 346
diff changeset
107 }
cin
parents: 346
diff changeset
108
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
109 my $prefix = $this->prefix;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
110
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
111 if (not(($args and delete $args->{'-no-resolve'}) or ref $model)) {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
112 $prefix = $prefix ? "${prefix}.${model}" : $model;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
113 $model = $this->resolve_model($model);
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
114 } else {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
115 $prefix = "";
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
116 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
117
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
118 $template = $template ? $this->find_template($template) : $this->find_template_for($model);
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
119
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
120 return $this->render(
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
121 $template,
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
122 hashApply(
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
123 {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
124 prefix => $prefix,
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
125 model => $model,
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
126 },
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
127 $args
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
128 )
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
129 );
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
130 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
131
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
132 sub invoke_environment {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
133 my ($this,$code,$env) = @_;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
134
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
135 $env ||= {};
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
136
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
137 my $out = eval {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
138 $this->localise(
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
139 hashApply(
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
140 {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
141 root => $this->root || $this,
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
142 cache => TypeKeyedCollection->new(),
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
143 display => sub {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
144 $this->display(@_);
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
145 },
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
146 render => sub {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
147 $this->render(@_);
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
148 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
149 },
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
150 $env
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
151 )
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
152 );
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
153
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
154 &$code($this);
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
155 };
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
156
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
157 my $e = $@;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
158 $this->delocalise();
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
159
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
160 die $e if $e;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
161
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
162 return $out;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
163 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
164
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
165 sub render {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
166 my ($this,$template,$args) = @_;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
167
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
168 $args ||= {};
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
169
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
170 #TODO handle classes
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
171
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
172 my $base;
347
cin
parents: 346
diff changeset
173
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
174 $template = $this->find_template($template) unless ref $template;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
175
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
176 if (ref $template eq 'HASH') {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
177 $base = $template->{base};
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
178 $template = $template->{template};
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
179 } else {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
180 carp "got an invalid template object: $template";
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
181 $base = $this->base;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
182 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
183
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
184 return $this->invoke_environment(
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
185 sub {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
186 return shift->include($template,$args);
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
187 },
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
188 {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
189 base => $base,
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
190 parent => $this
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
191 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
192 )
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
193 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
194
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
195 sub resolve_model {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
196 my ($this,$prefix) = @_;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
197
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
198 die ArgException->new(prefix => "the prefix must be specified")
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
199 unless defined $prefix;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
200
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
201 #TODO handle DOM models
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
202
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
203 my @comp = map { $_, 0 } grep length($_), split(/\.|\[(\d+)\]/, $prefix);
347
cin
parents: 346
diff changeset
204
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
205 return $this->stash->get(['model',0,@comp]);
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
206 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
207
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
208 sub find_template_for {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
209 my ($this,$model) = @_;
347
cin
parents: 346
diff changeset
210
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
211 my $type = typeof($model);
347
cin
parents: 346
diff changeset
212
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
213 return $this->find_template('templates/plain') unless $type;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
214
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
215 if (my $template = $this->cache->Get($type)) {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
216 return $template;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
217 } else {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
218
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
219 no strict 'refs';
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
220
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
221 my @isa = $type;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
222
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
223 while (@isa) {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
224 my $sclass = shift @isa;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
225
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
226 (my $name = $sclass) =~ s/:+/_/g;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
227
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
228 $template = $this->find_template("templates/$name");
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
229
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
230 if ($template) {
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
231 $this->cache->Set($sclass,$template);
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
232 return $template;
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
233 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
234
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
235 push @isa, @{"${sclass}::ISA"};
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
236 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
237
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
238 }
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
239
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
240 return;
347
cin
parents: 346
diff changeset
241 }
cin
parents: 346
diff changeset
242
345
cin
parents: 343
diff changeset
243 1;
cin
parents: 343
diff changeset
244
cin
parents: 343
diff changeset
245 __END__
cin
parents: 343
diff changeset
246
cin
parents: 343
diff changeset
247 =pod
cin
parents: 343
diff changeset
248
cin
parents: 343
diff changeset
249 =head1 NAME
cin
parents: 343
diff changeset
250
cin
parents: 343
diff changeset
251 C<IMPL::Web::View::TTContext> - доработанная версия контекста
cin
parents: 343
diff changeset
252
cin
parents: 343
diff changeset
253 =head1 DESCRIPTION
cin
parents: 343
diff changeset
254
cin
parents: 343
diff changeset
255 Расширяет функции C<Template::Context>
cin
parents: 343
diff changeset
256
cin
parents: 343
diff changeset
257 =begin plantuml
cin
parents: 343
diff changeset
258
cin
parents: 343
diff changeset
259 @startuml
cin
parents: 343
diff changeset
260
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
261 object RootContext {
345
cin
parents: 343
diff changeset
262 document
346
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
263 globals
345
cin
parents: 343
diff changeset
264 }
cin
parents: 343
diff changeset
265
cin
parents: 343
diff changeset
266 object DocumentContext {
346
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
267 base
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
268 extends
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
269 }
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
270
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
271 object ControlContext {
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
272 base
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
273 extends
345
cin
parents: 343
diff changeset
274 }
cin
parents: 343
diff changeset
275
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
276 RootContext o-- DocumentContext
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
277 RootContext o-- ControlContext
345
cin
parents: 343
diff changeset
278
346
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
279 Document -- DocumentContext
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
280 Control - ControlContext
345
cin
parents: 343
diff changeset
281
348
f116cd9fe7d9 working on TTView: pre-alpha version
cin
parents: 347
diff changeset
282 Loader . RootContext: <<creates>>
346
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
283 Loader . Document: <<creates>>
f05634287ac7 working on the view concept
cin
parents: 345
diff changeset
284 Loader -up- Registry
345
cin
parents: 343
diff changeset
285
cin
parents: 343
diff changeset
286 @enduml
cin
parents: 343
diff changeset
287
cin
parents: 343
diff changeset
288 =end plantuml
cin
parents: 343
diff changeset
289
cin
parents: 343
diff changeset
290 =head1 MEMBERS
cin
parents: 343
diff changeset
291
cin
parents: 343
diff changeset
292 =head2 C<[get,set]base>
cin
parents: 343
diff changeset
293
cin
parents: 343
diff changeset
294 Префикс пути для поиска шаблонов
cin
parents: 343
diff changeset
295
cin
parents: 343
diff changeset
296 =head2 C<template($name)>
cin
parents: 343
diff changeset
297
cin
parents: 343
diff changeset
298 Сначала пытается загрузить шаблон используя префикс C<base>, затем без префикса.
cin
parents: 343
diff changeset
299
cin
parents: 343
diff changeset
300 =head2 C<clone()>
cin
parents: 343
diff changeset
301
cin
parents: 343
diff changeset
302 Создает копию контекста, при этом C<stash> локализуется, таким образом
cin
parents: 343
diff changeset
303 клонированный контекст имеет собственное пространство имен, вложенное в
cin
parents: 343
diff changeset
304 пространство родительского контекста.
cin
parents: 343
diff changeset
305
cin
parents: 343
diff changeset
306 =cut