comparison Lib/IMPL/Web/View/TTRegistry.pm @ 304:2ff513227cb4

*TTView: refactoring. Added control registry for the document.
author cin
date Mon, 15 Apr 2013 07:44:50 +0400
parents
children b5d5793f348e
comparison
equal deleted inserted replaced
303:a5eb64c6e6f7 304:2ff513227cb4
1 package IMPL::Web::View::TTRegistry;
2 use strict;
3
4 use IMPL::Const qw(:prop);
5 use IMPL::declare {
6 require => {
7 TTFactory => 'IMPL::Web::View::TTFactory'
8 },
9 base => [
10 'IMPL::Object' => undef
11 ],
12 props => [
13 loader => PROP_RW,
14 context => PROP_RW,
15 _cache => PROP_RW,
16 ]
17 };
18
19 sub Require {
20 my ($this,$name) = @_;
21
22 if(my $factory = $this->_cache->{$name}) {
23 return $factory;
24 } else {
25 my $template = $this->loader->template($name)
26 or die AppException->new("Failed to load a template $name");
27
28 $factory = TTFactory->new(
29 $template,
30 $this->context,
31 $name,
32 $this
33 );
34
35 $this->_cache->{$name} = $factory;
36 return $factory;
37 }
38 }
39
40 1;
41
42 __END__