annotate Lib/IMPL/Web/TT/Control.pm @ 107:0e72ad99eef7

Updated Web::TT
author wizard
date Thu, 13 May 2010 03:46:29 +0400
parents a5cb84374d40
children c6fb6964de4c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
1 package IMPL::Web::TT::Control;
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
2
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
3 use base qw(IMPL::DOM::Node);
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
4
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
5 use IMPL::Class::Property;
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
6
107
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
7 __PACKAGE__->PassThroughArgs;
78
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
8
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
9 BEGIN {
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
10 public property template => prop_all;
107
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
11 public property id => prop_all;
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
12 }
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
13
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
14 my $nextId = 1;
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
15
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
16 sub CTOR {
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
17 my ($this,%args) = @_;
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
18
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
19 $this->template($args{template}) if $args{template};
0e72ad99eef7 Updated Web::TT
wizard
parents: 78
diff changeset
20 $this->id($this->nodeName . '-' . $nextId++);
78
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
21 }
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
22
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
23 sub Render {
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
24 my ($this) = @_;
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
25
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
26 if ($this->document) {
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
27 if ($this->template) {
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
28 return $this->document->context->include($this->template,{ this => $this });
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
29 } elsif ($this->document->presenter) {
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
30 return $this->document->presenter->print($this);
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
31 } else {
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
32 return $this->toString();
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
33 }
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
34 }
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
35 }
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
36
a5cb84374d40 TT::Control in work
wizard
parents:
diff changeset
37 1;