Mercurial > pub > Impl
annotate Lib/IMPL/Web/View/TTRegistry.pm @ 348:f116cd9fe7d9
working on TTView: pre-alpha version
author | cin |
---|---|
date | Thu, 03 Oct 2013 19:48:57 +0400 |
parents | 72799d1211c5 |
children |
rev | line source |
---|---|
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
1 package IMPL::Web::View::TTRegistry; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
2 use strict; |
305 | 3 use mro; |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
4 |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
5 use IMPL::Const qw(:prop); |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
6 use IMPL::declare { |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
7 require => { |
309 | 8 TTFactory => 'IMPL::Web::View::TTFactory', |
9 TTControl => '-IMPL::Web::View::TTControl' | |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
10 }, |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
11 base => [ |
345 | 12 'IMPL::Object' => undef |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
13 ], |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
14 props => [ |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
15 context => PROP_RW, |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
16 _cache => PROP_RW, |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
17 ] |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
18 }; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
19 |
305 | 20 sub CTOR { |
345 | 21 my ($this,$context) = @_; |
22 | |
305 | 23 $this->context($context); |
24 $this->_cache({}); | |
25 } | |
26 | |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
27 sub Require { |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
28 my ($this,$name) = @_; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
29 |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
30 if(my $factory = $this->_cache->{$name}) { |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
31 return $factory; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
32 } else { |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
33 my $template = $this->loader->template($name) |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
34 or die AppException->new("Failed to load a template $name"); |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
35 |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
36 $factory = TTFactory->new( |
309 | 37 $template->class || TTControl, |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
38 $template, |
345 | 39 $this->context->clone, |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
40 $name, |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
41 $this |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
42 ); |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
43 |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
44 $this->_cache->{$name} = $factory; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
45 return $factory; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
46 } |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
47 } |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
48 |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
49 1; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
50 |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
51 __END__ |
305 | 52 |
53 =pod | |
54 | |
55 =head1 NAME | |
56 | |
57 C<IMPL::Web::View::Registry> - реестр шаблонов документа. | |
58 | |
59 =head1 DESCRIPTION | |
60 | |
61 Используется для реализации функции C<require> внутри шаблонов. | |
62 | |
63 | |
64 | |
65 =cut |