comparison Lib/IMPL/Web/View/TTLoader.pm @ 195:7a920771fd8e

IMPL::Web::View changed document layout handling, docs, examples
author cin
date Wed, 11 Apr 2012 17:50:33 +0400
parents 4d0e1962161c
children a705e848dcc7
comparison
equal deleted inserted replaced
194:4d0e1962161c 195:7a920771fd8e
16 BEGIN { 16 BEGIN {
17 public property options => PROP_ALL; 17 public property options => PROP_ALL;
18 public property provider => PROP_GET | PROP_OWNERSET; 18 public property provider => PROP_GET | PROP_OWNERSET;
19 public property context => PROP_GET | PROP_OWNERSET; 19 public property context => PROP_GET | PROP_OWNERSET;
20 public property ext => PROP_ALL; 20 public property ext => PROP_ALL;
21 public property layoutBase => PROP_GET | PROP_OWNERSET;
21 22
22 public property isInitialized => PROP_GET | PROP_OWNERSET; 23 public property isInitialized => PROP_GET | PROP_OWNERSET;
23 public property initializer => PROP_GET | PROP_OWNERSET; 24 public property initializer => PROP_GET | PROP_OWNERSET;
24 25
25 private property _globals => PROP_ALL; 26 private property _globals => PROP_ALL;
33 $this->ext($args{ext}) if $args{ext}; 34 $this->ext($args{ext}) if $args{ext};
34 $this->initializer($args{initializer}) if $args{initializer}; 35 $this->initializer($args{initializer}) if $args{initializer};
35 $this->_globals(ref $args{globals} eq 'HASH' ? $args{globals} : {}); 36 $this->_globals(ref $args{globals} eq 'HASH' ? $args{globals} : {});
36 37
37 $this->options($refOpts); 38 $this->options($refOpts);
39 $this->layoutBase($args{layoutBase}) if $args{layoutBase};
38 40
39 # to aviod cyclic references we need to do a copy of $refOpts 41 # to aviod cyclic references we need to do a copy of $refOpts
40 $refOpts->{LOAD_TEMPLATES} = $this->provider(new Template::Provider( { %$refOpts } )); 42 $refOpts->{LOAD_TEMPLATES} = $this->provider(new Template::Provider( { %$refOpts } ));
41 43
42 $this->context(new Template::Context($refOpts)); 44 $this->context(new Template::Context($refOpts));
73 } elsif (defined $error and $error == STATUS_ERROR) { 75 } elsif (defined $error and $error == STATUS_ERROR) {
74 die new IMPL::Exception("Failed to load a template", $name, $tt); 76 die new IMPL::Exception("Failed to load a template", $name, $tt);
75 } 77 }
76 78
77 return $tt; 79 return $tt;
80 }
81
82 sub layout {
83 my ($this,$name) = @_;
84
85 my $layout;
86
87 if ($this->layoutBase) {
88 $layout = $this->layoutBase . "/";
89 }
90
91 $layout .= $name;
92 return $this->template($layout);
78 } 93 }
79 94
80 sub _appendExt { 95 sub _appendExt {
81 my ($this,$name) = @_; 96 my ($this,$name) = @_;
82 97