Mercurial > pub > Impl
comparison Lib/IMPL/Web/View/TTLoader.pm @ 309:5e4e7c8fbca1
sync
author | cin |
---|---|
date | Fri, 19 Apr 2013 00:27:51 +0400 |
parents | 47a09a8dc23a |
children | 0a9d51cf6dfd |
comparison
equal
deleted
inserted
replaced
308:47a09a8dc23a | 309:5e4e7c8fbca1 |
---|---|
6 use IMPL::Const qw(:prop); | 6 use IMPL::Const qw(:prop); |
7 use IMPL::declare { | 7 use IMPL::declare { |
8 require => { | 8 require => { |
9 Provider => 'Template::Provider', | 9 Provider => 'Template::Provider', |
10 Context => 'Template::Context', | 10 Context => 'Template::Context', |
11 TTRegistry => 'IMPL::Web::View::TTRegistry', | |
11 TTFactory => 'IMPL::Web::View::TTFactory', | 12 TTFactory => 'IMPL::Web::View::TTFactory', |
13 TTDocument => '-IMPL::Web::View::TTDocument', | |
12 Exception => 'IMPL::Exception', | 14 Exception => 'IMPL::Exception', |
13 ArgumentException => '-IMPL::InvalidArgumentException', | 15 ArgumentException => '-IMPL::InvalidArgumentException', |
14 KeyNotFoundException => '-IMPL::KeyNotFoundException' | 16 KeyNotFoundException => '-IMPL::KeyNotFoundException' |
15 }, | 17 }, |
16 base => [ | 18 base => [ |
69 } | 71 } |
70 | 72 |
71 sub document { | 73 sub document { |
72 my ($this,$name,$vars) = @_; | 74 my ($this,$name,$vars) = @_; |
73 | 75 |
74 $vars ||= $vars; | 76 $vars ||= {}; |
75 | 77 |
76 my $tt = $this->template($name); | 78 my $tt = $this->template($name); |
77 | 79 |
78 $this->_init(); | 80 $this->_init(); |
79 | 81 |
81 | 83 |
82 $this->context->localise(); | 84 $this->context->localise(); |
83 my $ctx = _clone_context($this->context); | 85 my $ctx = _clone_context($this->context); |
84 $this->context->delocalise(); | 86 $this->context->delocalise(); |
85 | 87 |
86 my $factory = TTFactory->new($tt,$ctx,$name,TTRegistry->new($this, $ctx)); | 88 my $registry = TTRegistry->new($this, $ctx); |
87 | 89 |
88 return $factory->new( $vars ); | 90 my $factory = TTFactory->new($tt->class || TTDocument, $tt, $ctx, $name, $registry); |
91 | |
92 $vars->{registry} = $registry; | |
93 | |
94 return $factory->new( $vars ); | |
89 } | 95 } |
90 | 96 |
91 | 97 |
92 sub template { | 98 sub template { |
93 my ($this,$name) = @_; | 99 my ($this,$name) = @_; |