Mercurial > pub > Impl
annotate Lib/IMPL/Web/TT/Control.pm @ 118:79cdd6c86409
JSON support (experimental)
| author | wizard |
|---|---|
| date | Mon, 07 Jun 2010 08:21:26 +0400 |
| parents | 0475eb382085 |
| children | a7efb3117295 |
| 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 |
| 117 | 22 $args{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
|
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) { | |
| 117 | 35 return $this->document->context->include($this->template,{ this => $this }) ; |
| 78 | 36 } elsif ($this->document->presenter) { |
| 37 return $this->document->presenter->print($this); | |
| 38 } else { | |
| 117 | 39 return $this->toString().": ".$this->controlClass() . ": ".$this->path; |
| 78 | 40 } |
| 41 } | |
| 42 } | |
| 43 | |
| 44 1; |
