Mercurial > pub > Impl
comparison Lib/IMPL/Web/View/TTControl.pm @ 189:08015e2803f1
IMPL::Vew::Web - fixed memory leaks, more tests
| author | cin |
|---|---|
| date | Wed, 04 Apr 2012 02:49:45 +0400 |
| parents | 029c9610528c |
| children | 78a18a2b6266 |
comparison
equal
deleted
inserted
replaced
| 188:029c9610528c | 189:08015e2803f1 |
|---|---|
| 34 $this->template( $template ) or die new IMPL::ArgumentException("A template is required"); | 34 $this->template( $template ) or die new IMPL::ArgumentException("A template is required"); |
| 35 $this->context( $context ) or die new IMPL::ArgumentException("A context is required"); | 35 $this->context( $context ) or die new IMPL::ArgumentException("A context is required"); |
| 36 | 36 |
| 37 if ( my $ctor = $template->blocks->{CTOR} ) { | 37 if ( my $ctor = $template->blocks->{CTOR} ) { |
| 38 $context->process($ctor, { this => $this } ); | 38 $context->process($ctor, { this => $this } ); |
| 39 $this->templateVars('this',undef); | 39 $context->stash->set('this',undef); |
| 40 } | 40 } |
| 41 | 41 |
| 42 $this->id($name . "-" . _GetNextId()) unless $this->id; | 42 $this->id($name . "-" . _GetNextId()) unless $this->id; |
| 43 | 43 |
| 44 } | 44 } |
| 48 nodeName => $_[0], | 48 nodeName => $_[0], |
| 49 %{ $_[3] || {} } | 49 %{ $_[3] || {} } |
| 50 } | 50 } |
| 51 ); | 51 ); |
| 52 | 52 |
| 53 sub templateVars { | |
| 54 my $this = shift; | |
| 55 my $name = shift; | |
| 56 | |
| 57 if (@_) { | |
| 58 return $this->context->stash->set($name, shift); | |
| 59 } else { | |
| 60 return $this->context->stash->get($name); | |
| 61 } | |
| 62 } | |
| 63 | |
| 64 sub renderBlock { | 53 sub renderBlock { |
| 65 $_[0]->template->blocks->{RENDER}; | 54 $_[0]->template->blocks->{RENDER}; |
| 66 } | 55 } |
| 67 | 56 |
| 68 sub Render { | 57 sub Render { |
| 69 my ($this,$args) = @_; | 58 my ($this,$args) = @_; |
| 70 | 59 |
| 71 $args = {} unless ref $args eq 'HASH'; | 60 $args = {} unless ref $args eq 'HASH'; |
| 72 | 61 |
| 73 if(my $body = $this->renderBlock ) { | 62 if(my $body = $this->renderBlock ) { |
| 74 return $this->context->include( $body, { %$args, this => $this, template => $this->template } ); | 63 return $this->context->include( $body, { %$args, this => $this, template => $this->template, document => $this->document } ); |
| 75 } else { | 64 } else { |
| 76 return ""; | 65 return ""; |
| 77 } | 66 } |
| 78 } | 67 } |
| 79 | 68 |
