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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
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
cin
parents: 305
diff changeset
8 TTFactory => 'IMPL::Web::View::TTFactory',
cin
parents: 305
diff changeset
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
cin
parents: 309
diff changeset
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
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
20 sub CTOR {
345
cin
parents: 309
diff changeset
21 my ($this,$context) = @_;
cin
parents: 309
diff changeset
22
305
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
23 $this->context($context);
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
24 $this->_cache({});
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
25 }
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
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
cin
parents: 305
diff changeset
37 $template->class || TTControl,
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
38 $template,
345
cin
parents: 309
diff changeset
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
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
52
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
53 =pod
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
54
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
55 =head1 NAME
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
56
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
57 C<IMPL::Web::View::Registry> - реестр шаблонов документа.
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
58
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
59 =head1 DESCRIPTION
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
60
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
61 Используется для реализации функции C<require> внутри шаблонов.
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
62
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
63
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
64
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
65 =cut