Mercurial > pub > Impl
changeset 234:2530d1bb9638
sync
author | sergey |
---|---|
date | Thu, 11 Oct 2012 20:11:45 +0400 |
parents | 3cebcf6fdb9b |
children | a4d9126edcbb |
files | Lib/IMPL/Web/View/TTControl.pm Lib/IMPL/Web/View/TTDocument.pm |
diffstat | 2 files changed, 24 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTControl.pm Thu Oct 11 04:53:08 2012 +0400 +++ b/Lib/IMPL/Web/View/TTControl.pm Thu Oct 11 20:11:45 2012 +0400 @@ -1,15 +1,28 @@ package IMPL::Web::View::TTControl; use strict; -use IMPL::DOM::Property qw(_dom); -use IMPL::lang qw(:declare ); - -use Template::Context(); use Scalar::Util qw(weaken); -use parent qw( - IMPL::DOM::Node -); +use IMPL::Const qw(:prop); +use IMPL::declare { + require => { + TTContext => 'Template::Context', + Exception => 'IMPL::Exception', + ArgumentException => '-IMPL::InvalidArgumentException' + }, + base => [ + 'IMPL::DOM::Node' => sub { + nodeName => $_[0], + %{ $_[3] || {} } + } + ], + props => [ + id => PROP_RO, + context => PROP_RO, + template => PROP_RO + ] +}; + { my $nextId = 1; @@ -18,15 +31,6 @@ } } - -BEGIN { - public _dom property id => PROP_ALL; - - public property context => PROP_GET | PROP_OWNERSET; - public property template => PROP_ALL; -} - - sub CTOR { my ($this,$name,$template,$context,$refProps) = @_; @@ -37,20 +41,12 @@ $this->id($name . "-" . _GetNextId()) unless $this->id; - weaken($this); # prevent cyclic references produces by the code below + weaken($this); # prevent cyclic references produced by the code below $context->stash->set('append', sub { $this->appendChild(@_); undef; } ); $context->stash->set('select', sub { $this->selectNodes(@_); } ); - } -our %CTOR = ( - 'IMPL::DOM::Node' => sub { - nodeName => $_[0], - %{ $_[3] || {} } - } -); - sub InitInstance { my ($this,$args) = @_; @@ -61,7 +57,7 @@ } } -sub renderBlock { +sub GetRenderBlock { $_[0]->template->blocks->{RENDER} || $_[0]->template; } @@ -70,7 +66,7 @@ $args = {} unless ref $args eq 'HASH'; - if(my $body = $this->renderBlock ) { + if(my $body = $this->GetRenderBlock ) { return $this->context->include( $body, { %$args, this => $this, template => $this->template, document => $this->document } ); } else { return "";
--- a/Lib/IMPL/Web/View/TTDocument.pm Thu Oct 11 04:53:08 2012 +0400 +++ b/Lib/IMPL/Web/View/TTDocument.pm Thu Oct 11 20:11:45 2012 +0400 @@ -120,7 +120,7 @@ $this->loader->layout($this->layout), { %{$args || {}}, - content => sub { $output ||= $this->RenderContent($args); }, + content => sub { $this->RenderContent($args); }, this => $this, template => $this->template }