Mercurial > pub > Impl
comparison Lib/IMPL/Web/View/TTContext.pm @ 356:97131d500f16
TTView: added identifiers support
author | cin |
---|---|
date | Thu, 17 Oct 2013 17:48:50 +0400 |
parents | 8dfb9df07d02 |
children | 833e663796c4 |
comparison
equal
deleted
inserted
replaced
355:8dfb9df07d02 | 356:97131d500f16 |
---|---|
32 prefix | 32 prefix |
33 cache | 33 cache |
34 includes | 34 includes |
35 modules | 35 modules |
36 aliases | 36 aliases |
37 id | |
37 )) { | 38 )) { |
38 my $t = $prop; | 39 my $t = $prop; |
39 | 40 |
40 *{__PACKAGE__ . '::' . $prop} = sub { | 41 *{__PACKAGE__ . '::' . $prop} = sub { |
41 my $this = shift; | 42 my $this = shift; |
61 my $clone = $class->new($args); | 62 my $clone = $class->new($args); |
62 | 63 |
63 $clone->stash->update($params) if $params; | 64 $clone->stash->update($params) if $params; |
64 | 65 |
65 return $clone; | 66 return $clone; |
67 } | |
68 | |
69 sub get_next_id { | |
70 my ($this) = @_; | |
71 | |
72 my $id = $this->stash->get('document.nextId') || 0; | |
73 $this->stash->set('document.nextId', $id + 1); | |
74 return "w-$id"; | |
66 } | 75 } |
67 | 76 |
68 sub find_template { | 77 sub find_template { |
69 my ($this,$name) = @_; | 78 my ($this,$name) = @_; |
70 | 79 |
265 $ctx->leave(); | 274 $ctx->leave(); |
266 } | 275 } |
267 } | 276 } |
268 | 277 |
269 if (my $class = $info->{class}) { | 278 if (my $class = $info->{class}) { |
270 $class->new($this,$info->{template})->Render($args); | 279 $class->new($ctx,$info->{template},$args)->Render($args); |
271 } else { | 280 } else { |
272 return $ctx->include($info->{template},$args); | 281 return $ctx->include($info->{template},$args); |
273 } | 282 } |
274 }, | 283 }, |
275 hashMerge( | 284 hashMerge( |
276 $info->{labels} || {}, | 285 $info->{labels} || {}, |
277 { | 286 { |
278 base => $info->{base}, | 287 base => $info->{base}, |
279 parent => $this | 288 parent => $this, |
289 id => $this->get_next_id | |
280 } | 290 } |
281 ) | 291 ) |
282 ) | 292 ) |
283 } | 293 } |
284 | 294 |
286 my ($this,$prefix,$args) = @_; | 296 my ($this,$prefix,$args) = @_; |
287 | 297 |
288 die ArgException->new(prefix => "the prefix must be specified") | 298 die ArgException->new(prefix => "the prefix must be specified") |
289 unless defined $prefix; | 299 unless defined $prefix; |
290 | 300 |
291 #TODO handle DOM models | 301 |
292 | 302 |
293 if (my $res = $this->stash->get(['resolver', [$this,$prefix,$args]] ) ) { | 303 if (my $res = $this->stash->get(['resolve', [$this,$prefix,$args]] ) ) { |
294 return $res; | 304 return $res; |
295 } | 305 } |
296 | 306 |
297 my @comp = map { $_, 0 } grep length($_), split(/\.|\[(\d+)\]/, $prefix); | 307 my @comp = map { $_, 0 } grep length($_), split(/\.|\[(\d+)\]/, $prefix); |
298 | 308 |