Mercurial > pub > Impl
annotate Lib/IMPL/Web/TT/Control.pm @ 109:ddf0f037d460
IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
Some fixes to the web document model. (beta version)
author | wizard |
---|---|
date | Mon, 17 May 2010 05:12:08 +0400 |
parents | c6fb6964de4c |
children | 0475eb382085 |
rev | line source |
---|---|
78 | 1 package IMPL::Web::TT::Control; |
2 | |
108 | 3 use base qw(IMPL::Web::TT::Collection); |
78 | 4 |
5 use IMPL::Class::Property; | |
6 | |
107 | 7 __PACKAGE__->PassThroughArgs; |
78 | 8 |
9 BEGIN { | |
108 | 10 public property controlClass => prop_all; |
78 | 11 public property template => prop_all; |
107 | 12 public property id => prop_all; |
13 } | |
14 | |
15 my $nextId = 1; | |
16 | |
17 sub CTOR { | |
18 my ($this,%args) = @_; | |
19 | |
109
ddf0f037d460
IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents:
108
diff
changeset
|
20 if ($this->document) { |
ddf0f037d460
IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents:
108
diff
changeset
|
21 # load a template |
ddf0f037d460
IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents:
108
diff
changeset
|
22 #$args{template} = $this->document->context->template($args{template}) if ($args{template}); |
ddf0f037d460
IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents:
108
diff
changeset
|
23 } |
107 | 24 $this->template($args{template}) if $args{template}; |
109
ddf0f037d460
IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents:
108
diff
changeset
|
25 |
107 | 26 $this->id($this->nodeName . '-' . $nextId++); |
108 | 27 $this->controlClass($args{controlClass} || 'Control'); |
78 | 28 } |
29 | |
30 sub Render { | |
31 my ($this) = @_; | |
32 | |
33 if ($this->document) { | |
34 if ($this->template) { | |
35 return $this->document->context->include($this->template,{ this => $this }); | |
36 } elsif ($this->document->presenter) { | |
37 return $this->document->presenter->print($this); | |
38 } else { | |
39 return $this->toString(); | |
40 } | |
41 } | |
42 } | |
43 | |
44 1; |