Mercurial > pub > Impl
comparison Lib/IMPL/Web/View/TTLoader.pm @ 343:9bdccdf1f50b
Added a templates context
author | cin |
---|---|
date | Fri, 13 Sep 2013 12:53:15 +0400 |
parents | 86336d451b82 |
children | 72799d1211c5 |
comparison
equal
deleted
inserted
replaced
342:1090c1dd7429 | 343:9bdccdf1f50b |
---|---|
6 use File::Spec(); | 6 use File::Spec(); |
7 use IMPL::Const qw(:prop); | 7 use IMPL::Const qw(:prop); |
8 use IMPL::declare { | 8 use IMPL::declare { |
9 require => { | 9 require => { |
10 Provider => 'Template::Provider', | 10 Provider => 'Template::Provider', |
11 Context => 'Template::Context', | 11 Context => 'IMPL::Web::View::TTContext', |
12 TTRegistry => 'IMPL::Web::View::TTRegistry', | 12 TTRegistry => 'IMPL::Web::View::TTRegistry', |
13 TTFactory => 'IMPL::Web::View::TTFactory', | 13 TTFactory => 'IMPL::Web::View::TTFactory', |
14 TTDocument => '-IMPL::Web::View::TTDocument', | 14 TTDocument => '-IMPL::Web::View::TTDocument', |
15 Exception => 'IMPL::Exception', | 15 Exception => 'IMPL::Exception', |
16 ArgumentException => '-IMPL::InvalidArgumentException', | 16 ArgumentException => '-IMPL::InvalidArgumentException', |
80 | 80 |
81 $this->_init(); | 81 $this->_init(); |
82 | 82 |
83 my $opts = { %{ $this->options } }; | 83 my $opts = { %{ $this->options } }; |
84 | 84 |
85 $this->context->localise(); | 85 my $ctx = $this->context->clone(); |
86 my $ctx = _clone_context($this->context); | |
87 $this->context->delocalise(); | |
88 | 86 |
89 $ctx->stash->update($vars); | 87 $ctx->stash->update($vars); |
90 | 88 |
91 my $registry = TTRegistry->new($this, $ctx); | 89 my $registry = TTRegistry->new($this, $ctx); |
92 | 90 |
153 die Exception->new("Failed to process an initializer", $this->initializer, $e); | 151 die Exception->new("Failed to process an initializer", $this->initializer, $e); |
154 } | 152 } |
155 | 153 |
156 $this->isInitialized(1); | 154 $this->isInitialized(1); |
157 } | 155 } |
158 } | |
159 | |
160 sub _clone_context { | |
161 my $args = { %{shift || {}} }; | |
162 delete $args->{CONFIG}; | |
163 | |
164 return Template::Context->new($args); | |
165 } | 156 } |
166 | 157 |
167 1; | 158 1; |
168 | 159 |
169 __END__ | 160 __END__ |