Mercurial > pub > Impl
annotate Lib/IMPL/Web/TT/Control.pm @ 177:df71a307ef9b
new constructor syntax
author | sourcer |
---|---|
date | Wed, 12 Oct 2011 00:04:13 +0300 |
parents | 59e5fcb59d86 |
children | d1676be8afcc |
rev | line source |
---|---|
78 | 1 package IMPL::Web::TT::Control; |
2 | |
166 | 3 use parent qw(IMPL::Web::TT::Collection); |
78 | 4 |
171 | 5 |
78 | 6 use IMPL::Class::Property; |
122 | 7 use IMPL::DOM::Property qw(_dom); |
78 | 8 |
107 | 9 __PACKAGE__->PassThroughArgs; |
78 | 10 |
11 BEGIN { | |
108 | 12 public property controlClass => prop_all; |
78 | 13 public property template => prop_all; |
107 | 14 public property id => prop_all; |
15 } | |
16 | |
17 my $nextId = 1; | |
18 | |
19 sub CTOR { | |
20 my ($this,%args) = @_; | |
21 | |
109
ddf0f037d460
IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents:
108
diff
changeset
|
22 if ($this->document) { |
ddf0f037d460
IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents:
108
diff
changeset
|
23 # load a template |
140
fb896377389f
to_json and escape_string functions for the templates
wizard
parents:
126
diff
changeset
|
24 $this->template( $this->document->context->template($args{template})) if ($args{template} and not ref $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 } |
126 | 26 #$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
|
27 |
107 | 28 $this->id($this->nodeName . '-' . $nextId++); |
140
fb896377389f
to_json and escape_string functions for the templates
wizard
parents:
126
diff
changeset
|
29 $this->controlClass('Control') unless $this->controlClass; |
78 | 30 } |
31 | |
32 sub Render { | |
33 my ($this) = @_; | |
34 | |
35 if ($this->document) { | |
36 if ($this->template) { | |
117 | 37 return $this->document->context->include($this->template,{ this => $this }) ; |
78 | 38 } elsif ($this->document->presenter) { |
39 return $this->document->presenter->print($this); | |
40 } else { | |
117 | 41 return $this->toString().": ".$this->controlClass() . ": ".$this->path; |
78 | 42 } |
43 } | |
44 } | |
45 1; |