# HG changeset patch # User cin # Date 1380548177 -14400 # Node ID 3eafa6fefa9f444f150946f7525617cc90264d62 # Parent f05634287ac7d70fc5f6a147ea36484b1227eeb2 sync diff -r f05634287ac7 -r 3eafa6fefa9f Lib/IMPL/Web/View/TTContext.pm --- a/Lib/IMPL/Web/View/TTContext.pm Mon Sep 30 01:37:50 2013 +0400 +++ b/Lib/IMPL/Web/View/TTContext.pm Mon Sep 30 17:36:17 2013 +0400 @@ -12,8 +12,27 @@ } }; +BEGIN { + no strict 'ref'; + foreach my $prop (qw( + base + tt_ext + shared + parent + prefix + )) { + my $t = $prop; + + *{__PACKAGE__ . '::' . $name} = sub { + my $this = shift; + return @_ ? $this->stash->set($t, @_) : $this->stash->get($t); + } + } +} + sub clone { my $this = shift; + my $params = shift; $this->localise(); @@ -25,19 +44,11 @@ delete $args->{CONFIG}; - return $class->new($args); -} - -sub base { - my $this = shift; - - return @_ ? $this->stash->set('base', @_) : $this->stash->get('base'); -} - -sub tt_ext { - my $this = shift; - - return @_ ? $this->stash->set('tt_ext', @_) : $this->stash->get('tt_ext'); + my $clone = $class->new($args); + + $clone->stash->update($params) if $params; + + return $clone; } sub find_template { @@ -69,6 +80,30 @@ return $this->stash->get([ 'require', [$name] ]); } +sub display { + my $this = shift; + my $model = shift; + my $template, $args; + + if (ref $_[0] eq 'HASH') { + $args = shift; + } else { + $template = shift; + $args = shift; + } + + my $prefix = $this->prefix + + my $cloned = $this->clone({ + prefix => $prefix, + shared => $this->shared || $this, + parent => $this + }); + + + +} + 1; __END__