comparison Lib/IMPL/Web/View/TTLoader.pm @ 308:47a09a8dc23a

sync
author sergey
date Thu, 18 Apr 2013 20:06:05 +0400
parents 85572f512abc
children 5e4e7c8fbca1
comparison
equal deleted inserted replaced
307:2da2564f115d 308:47a09a8dc23a
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 TTDocument => 'IMPL::Web::View::TTDocument', 11 TTFactory => 'IMPL::Web::View::TTFactory',
12 Exception => 'IMPL::Exception', 12 Exception => 'IMPL::Exception',
13 ArgumentException => '-IMPL::InvalidArgumentException', 13 ArgumentException => '-IMPL::InvalidArgumentException',
14 KeyNotFoundException => '-IMPL::KeyNotFoundException' 14 KeyNotFoundException => '-IMPL::KeyNotFoundException'
15 }, 15 },
16 base => [ 16 base => [
69 } 69 }
70 70
71 sub document { 71 sub document {
72 my ($this,$name,$vars) = @_; 72 my ($this,$name,$vars) = @_;
73 73
74 $vars ||= $vars;
75
74 my $tt = $this->template($name); 76 my $tt = $this->template($name);
75 77
76 $this->_init(); 78 $this->_init();
77 79
78 my $opts = { %{ $this->options } }; 80 my $opts = { %{ $this->options } };
79 81
80 $this->context->localise(); 82 $this->context->localise();
81 my $ctx = _clone_context($this->context); 83 my $ctx = _clone_context($this->context);
82 $this->context->delocalise(); 84 $this->context->delocalise();
83 85
84 return TTDocument->new( $tt, $ctx, $this, $vars ); 86 my $factory = TTFactory->new($tt,$ctx,$name,TTRegistry->new($this, $ctx));
85 } 87
88 return $factory->new( $vars );
89 }
90
86 91
87 sub template { 92 sub template {
88 my ($this,$name) = @_; 93 my ($this,$name) = @_;
89 94
90 $name =~ s/^\s+|\s+$//g; 95 $name =~ s/^\s+|\s+$//g;