Mercurial > pub > Impl
changeset 310:0a9d51cf6dfd
*TTView: refactoring, document supports custom classes, layouts are become controls
author | sergey |
---|---|
date | Fri, 19 Apr 2013 16:39:01 +0400 |
parents | 5e4e7c8fbca1 |
children | d3b5a67ad2e8 |
files | Lib/IMPL/Web/View/TTDocument.pm Lib/IMPL/Web/View/TTLoader.pm |
diffstat | 2 files changed, 9 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTDocument.pm Fri Apr 19 00:27:51 2013 +0400 +++ b/Lib/IMPL/Web/View/TTDocument.pm Fri Apr 19 16:39:01 2013 +0400 @@ -42,10 +42,8 @@ my ($this,$args) = @_; $args ||= {}; + $args->{document} = $this; - $this->context->localise(); # localise stash - my $documentContext = _clone_context( $this->context ); # create a new context - $this->context->stash->update({ document => sub { $this } }); @@ -53,37 +51,20 @@ my $text = eval { if ($this->layout) { - my $tlayout = $this->registry->loader->layout($this->layout) - or die OpException->new('The specified layout isn\'t found', $this->layout); - if(my $init = $tlayout->blocks->{INIT}) { - $this->context->process( - $init, - hashMerge( - $args, - { - template => $this->template - } - ) - ); - } + my $layout = $this->registry->Require(join('/',$this->layoutBase, $this->layout))->new(); + my $content = $this->next::method($args); - return $this->context->include( - $tlayout, - { - %{$args}, - content => $content, - this => $this, - template => $this->template - } - ); + return $layout->Render({ + content => $content, + template => $this->template, + document => $this + }); } else { return $this->next::method($args); } }; my $e = $@; - - $this->context->delocalise(); undef $this;
--- a/Lib/IMPL/Web/View/TTLoader.pm Fri Apr 19 00:27:51 2013 +0400 +++ b/Lib/IMPL/Web/View/TTLoader.pm Fri Apr 19 16:39:01 2013 +0400 @@ -90,6 +90,7 @@ my $factory = TTFactory->new($tt->class || TTDocument, $tt, $ctx, $name, $registry); $vars->{registry} = $registry; + $vars->{layoutBase} = $this->layoutBase; return $factory->new( $vars ); } @@ -115,19 +116,6 @@ return $tt; } -sub layout { - my ($this,$name) = @_; - - my $layout; - - if ($this->layoutBase) { - $layout = $this->layoutBase . "/"; - } - - $layout .= $name; - return $this->template($layout); -} - sub _appendExt { my ($this,$name) = @_;