comparison Lib/IMPL/Web/View/TTDocument.pm @ 186:6c0fee769b0c

IMPL::Web::View::TTControl tests, fixes
author cin
date Fri, 30 Mar 2012 16:40:34 +0400
parents ae8072f2f2a3
children 927653d01f4f
comparison
equal deleted inserted replaced
185:ae8072f2f2a3 186:6c0fee769b0c
42 ); 42 );
43 43
44 sub require { 44 sub require {
45 my ($this, $control) = @_; 45 my ($this, $control) = @_;
46 46
47 if (! $this->controls->{$control}) { 47 if (my $factory = $this->controls->{$control}) {
48 return $factory;
49 } else {
48 50
49 (my $path = $control) =~ tr/\./\//; 51 my $path = $control;
50 if ( my $template = $this->loader->template($path) ) { 52 if ( my $template = $this->loader->template($path) ) {
51 my $opts = ${$this->opts}; 53 my $opts = { %{$this->opts} };
52 $opts->{STASH} = $this->context->stash->clone(); 54 $opts->{STASH} = $this->context->stash->clone();
53 55
54 my $ctx = new Template::Context($opts); 56 my $ctx = new Template::Context($opts);
55 57
56 my $factory = new IMPL::Web::View::TTFactory( 58 $factory = new IMPL::Web::View::TTFactory(
57 typeof IMPL::Web::View::TTControl, 59 typeof IMPL::Web::View::TTControl,
58 $template, 60 $template,
59 $ctx, 61 $ctx,
60 $opts 62 $opts
61 ); 63 );
62 64
63 my @parts = split(/\.+/,$control); 65 my @parts = split(/\/+/,$control);
64 66
67 $this->controls->{$control} = $factory;
65 $this->context->stash->set([map { $_, 0 } @parts], $factory); 68 $this->context->stash->set([map { $_, 0 } @parts], $factory);
66 69
70 return $factory;
67 } else { 71 } else {
68 die new IMPL::KeyNotFoundException($control); 72 die new IMPL::KeyNotFoundException($control);
69 } 73 }
70 74
71 } 75 }