comparison Lib/IMPL/Web/TT/Control.pm @ 194:4d0e1962161c

Replaced tabs with spaces IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author cin
date Tue, 10 Apr 2012 20:08:29 +0400
parents d1676be8afcc
children
comparison
equal deleted inserted replaced
193:8e8401c0aea4 194:4d0e1962161c
7 use IMPL::DOM::Property qw(_dom); 7 use IMPL::DOM::Property qw(_dom);
8 8
9 __PACKAGE__->PassThroughArgs; 9 __PACKAGE__->PassThroughArgs;
10 10
11 BEGIN { 11 BEGIN {
12 public property controlClass => prop_all; 12 public property controlClass => prop_all;
13 public property template => prop_all; 13 public property template => prop_all;
14 public property id => prop_all; 14 public property id => prop_all;
15 } 15 }
16 16
17 my $nextId = 1; 17 my $nextId = 1;
18 18
19 sub CTOR { 19 sub CTOR {
20 my ($this,%args) = @_; 20 my ($this,%args) = @_;
21 21
22 if ($this->document) { 22 if ($this->document) {
23 # load a template 23 # load a template
24 $this->template( $this->document->context->template($args{template})) if ($args{template} and not ref $args{template}); 24 $this->template( $this->document->context->template($args{template})) if ($args{template} and not ref $args{template});
25 } 25 }
26 #$this->template($args{template}) if $args{template}; 26 #$this->template($args{template}) if $args{template};
27 27
28 $this->id($this->nodeName . '-' . $nextId++); 28 $this->id($this->nodeName . '-' . $nextId++);
29 $this->controlClass('Control') unless $this->controlClass; 29 $this->controlClass('Control') unless $this->controlClass;
30 } 30 }
31 31
32 sub Render { 32 sub Render {
33 my ($this) = @_; 33 my ($this) = @_;
34 34
35 if ($this->document) { 35 if ($this->document) {
36 if ($this->template) { 36 if ($this->template) {
37 return $this->document->context->include($this->template,{ this => $this }) ; 37 return $this->document->context->include($this->template,{ this => $this }) ;
38 } elsif ($this->document->presenter) { 38 } elsif ($this->document->presenter) {
39 return $this->document->presenter->print($this); 39 return $this->document->presenter->print($this);
40 } else { 40 } else {
41 return $this->toString().": ".$this->controlClass() . ": ".$this->path; 41 return $this->toString().": ".$this->controlClass() . ": ".$this->path;
42 } 42 }
43 } 43 }
44 } 44 }
45 1; 45 1;