Mercurial > pub > Impl
changeset 356:97131d500f16
TTView: added identifiers support
author | cin |
---|---|
date | Thu, 17 Oct 2013 17:48:50 +0400 |
parents | 8dfb9df07d02 |
children | ec58c47edb52 |
files | Lib/IMPL/Web/View/TTContext.pm Lib/IMPL/Web/View/TTControl.pm |
diffstat | 2 files changed, 29 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTContext.pm Thu Oct 17 01:04:37 2013 +0400 +++ b/Lib/IMPL/Web/View/TTContext.pm Thu Oct 17 17:48:50 2013 +0400 @@ -34,6 +34,7 @@ includes modules aliases + id )) { my $t = $prop; @@ -65,6 +66,14 @@ return $clone; } +sub get_next_id { + my ($this) = @_; + + my $id = $this->stash->get('document.nextId') || 0; + $this->stash->set('document.nextId', $id + 1); + return "w-$id"; +} + sub find_template { my ($this,$name) = @_; @@ -267,7 +276,7 @@ } if (my $class = $info->{class}) { - $class->new($this,$info->{template})->Render($args); + $class->new($ctx,$info->{template},$args)->Render($args); } else { return $ctx->include($info->{template},$args); } @@ -276,7 +285,8 @@ $info->{labels} || {}, { base => $info->{base}, - parent => $this + parent => $this, + id => $this->get_next_id } ) ) @@ -288,9 +298,9 @@ die ArgException->new(prefix => "the prefix must be specified") unless defined $prefix; - #TODO handle DOM models + - if (my $res = $this->stash->get(['resolver', [$this,$prefix,$args]] ) ) { + if (my $res = $this->stash->get(['resolve', [$this,$prefix,$args]] ) ) { return $res; }
--- a/Lib/IMPL/Web/View/TTControl.pm Thu Oct 17 01:04:37 2013 +0400 +++ b/Lib/IMPL/Web/View/TTControl.pm Thu Oct 17 17:48:50 2013 +0400 @@ -13,22 +13,10 @@ ], props => [ context => PROP_RO, - template => PROP_RO, - id => { - get => sub { shift->_stash->get('id') }, - set => sub { shift->_stash->set('id',shift) } - } + template => PROP_RO ] }; - -{ - my $nextId = 1; - sub _GetNextId { - return '_' . $nextId++; - } -} - our $AUTOLOAD_REGEX = qr/^[a-z]/; sub CTOR { @@ -40,6 +28,20 @@ or die ArgException->new(template => 'A template is required'); } +sub _PopulateMethods { + my ($this,@methods) = @_; + + $this->_stash->update({ + map { + my $name = $_; + $name, + sub { + $this->$name(@_); + } + } @methods + }); +} + sub _stash { $_[0]->context->stash; }