comparison Lib/IMPL/Web/View/TTContext.pm @ 347:3eafa6fefa9f

sync
author cin
date Mon, 30 Sep 2013 17:36:17 +0400
parents f05634287ac7
children f116cd9fe7d9
comparison
equal deleted inserted replaced
346:f05634287ac7 347:3eafa6fefa9f
10 base => { 10 base => {
11 'Template::Context' => '@_' 11 'Template::Context' => '@_'
12 } 12 }
13 }; 13 };
14 14
15 BEGIN {
16 no strict 'ref';
17 foreach my $prop (qw(
18 base
19 tt_ext
20 shared
21 parent
22 prefix
23 )) {
24 my $t = $prop;
25
26 *{__PACKAGE__ . '::' . $name} = sub {
27 my $this = shift;
28 return @_ ? $this->stash->set($t, @_) : $this->stash->get($t);
29 }
30 }
31 }
32
15 sub clone { 33 sub clone {
16 my $this = shift; 34 my $this = shift;
35 my $params = shift;
17 36
18 $this->localise(); 37 $this->localise();
19 38
20 my $args = { %{$this} }; 39 my $args = { %{$this} };
21 40
23 42
24 my $class = typeof($this); 43 my $class = typeof($this);
25 44
26 delete $args->{CONFIG}; 45 delete $args->{CONFIG};
27 46
28 return $class->new($args); 47 my $clone = $class->new($args);
29 } 48
30 49 $clone->stash->update($params) if $params;
31 sub base { 50
32 my $this = shift; 51 return $clone;
33
34 return @_ ? $this->stash->set('base', @_) : $this->stash->get('base');
35 }
36
37 sub tt_ext {
38 my $this = shift;
39
40 return @_ ? $this->stash->set('tt_ext', @_) : $this->stash->get('tt_ext');
41 } 52 }
42 53
43 sub find_template { 54 sub find_template {
44 my ($this,$name,@inc) = @_; 55 my ($this,$name,@inc) = @_;
45 56
65 76
66 sub require { 77 sub require {
67 my ($this,$name) = @_; 78 my ($this,$name) = @_;
68 79
69 return $this->stash->get([ 'require', [$name] ]); 80 return $this->stash->get([ 'require', [$name] ]);
81 }
82
83 sub display {
84 my $this = shift;
85 my $model = shift;
86 my $template, $args;
87
88 if (ref $_[0] eq 'HASH') {
89 $args = shift;
90 } else {
91 $template = shift;
92 $args = shift;
93 }
94
95 my $prefix = $this->prefix
96
97 my $cloned = $this->clone({
98 prefix => $prefix,
99 shared => $this->shared || $this,
100 parent => $this
101 });
102
103
104
70 } 105 }
71 106
72 1; 107 1;
73 108
74 __END__ 109 __END__