comparison Lib/IMPL/Web/TT/Document.pm @ 107:0e72ad99eef7

Updated Web::TT
author wizard
date Thu, 13 May 2010 03:46:29 +0400
parents 964587c5183c
children c6fb6964de4c
comparison
equal deleted inserted replaced
106:83e356614c1e 107:0e72ad99eef7
6 use Template::Context; 6 use Template::Context;
7 use Template::Provider; 7 use Template::Provider;
8 use IMPL::Class::Property; 8 use IMPL::Class::Property;
9 use File::Spec; 9 use File::Spec;
10 use Scalar::Util qw(blessed); 10 use Scalar::Util qw(blessed);
11 use IMPL::Web::TT::Collection;
12 use IMPL::Web::TT::Control;
11 13
12 BEGIN { 14 BEGIN {
13 private property _provider => prop_all; 15 private property _provider => prop_all;
14 private property _context => prop_all; 16 private property _context => prop_all;
15 public property template => prop_get | owner_set; 17 public property template => prop_get | owner_set;
16 public property presenter => prop_all, { validate => \&_validatePresenter }; 18 public property presenter => prop_all, { validate => \&_validatePresenter };
19 public property controls => { get => \&_getControls };
17 } 20 }
18 21
19 our %CTOR = ( 22 our %CTOR = (
20 'IMPL::DOM::Document' => sub { nodeName => 'document' } 23 'IMPL::DOM::Document' => sub { nodeName => 'document' }
21 ); 24 );
25
26 sub CTOR {
27 my ($this) = @_;
28
29 $this->appendChild(
30 $this->Create(
31 controls => 'IMPL::Web::TT::Collection'
32 )
33 )
34 }
22 35
23 sub provider { 36 sub provider {
24 my ($this,%args) = @_; 37 my ($this,%args) = @_;
25 38
26 if (my $provider = $this->_provider) { 39 if (my $provider = $this->_provider) {
43 VARIABLES => { 56 VARIABLES => {
44 document => $this, 57 document => $this,
45 this => $this, 58 this => $this,
46 render => sub { 59 render => sub {
47 $this->_process(@_); 60 $this->_process(@_);
48 } 61 },
62 controls => $this->controls
49 }, 63 },
50 TRIM => 1, 64 TRIM => 1,
51 RECURSION => 1, 65 RECURSION => 1,
52 LOAD_TEMPLATES => [$this->provider] 66 LOAD_TEMPLATES => [$this->provider]
53 ) 67 )
54 ) 68 )
55 } 69 }
70 }
71
72 sub createControl {
73 my ($this,$name,$args) = @_;
74
75 my $node = $this->Create($name,'IMPL::Web::TT::Control',$args);
76 $this->controls->appendChild($node);
77 }
78
79 sub _getControls {
80 my ($this) = @_;
81
82 my ($node) = $this->selectNodes('controls');
83 return $node;
56 } 84 }
57 85
58 sub _validatePresenter { 86 sub _validatePresenter {
59 my ($this,$value) = @_; 87 my ($this,$value) = @_;
60 88
120 } else { 148 } else {
121 push @result, $item; 149 push @result, $item;
122 } 150 }
123 } 151 }
124 152
125 return join '',@items; 153 return join '',@result;
126 } 154 }
127 155
128 sub Dispose { 156 sub Dispose {
129 my ($this) = @_; 157 my ($this) = @_;
130 158