comparison Lib/IMPL/Web/Handler/TTView.pm @ 291:5d14baa35790

*TTView: fixed template selectors mechanism
author cin
date Thu, 21 Feb 2013 03:44:02 +0400
parents 546957c50a36
children 71221d79e6b4
comparison
equal deleted inserted replaced
290:7b0dad6117d5 291:5d14baa35790
1 package IMPL::Web::Handler::TTView; 1 package IMPL::Web::Handler::TTView;
2 use strict; 2 use strict;
3 3
4 use Carp qw(carp);
4 use List::Util qw(first); 5 use List::Util qw(first);
5 use IMPL::lang; 6 use IMPL::lang;
6 use IMPL::Const qw(:prop); 7 use IMPL::Const qw(:prop);
7 use IMPL::declare { 8 use IMPL::declare {
8 require => { 9 require => {
53 action => $action, 54 action => $action,
54 app => $action->application, 55 app => $action->application,
55 env => _cached($action->context->{environment}), 56 env => _cached($action->context->{environment}),
56 ImportClass => sub { 57 ImportClass => sub {
57 my $class = shift; 58 my $class = shift;
59
60 carp "ImportClass is obsolete use import instead";
61
62 $class = Loader->safe->Require($class);
63
64 return Factory->new($class);
65 },
66 import => sub {
67 my $class = shift;
58 68
59 $class = Loader->safe->Require($class); 69 $class = Loader->safe->Require($class);
60 70
61 return Factory->new($class); 71 return Factory->new($class);
62 } 72 }
166 foreach my $segment (@$path) { 176 foreach my $segment (@$path) {
167 foreach my $rule (@$rules) { 177 foreach my $rule (@$rules) {
168 my @selector = @{$rule->{selector}}; 178 my @selector = @{$rule->{selector}};
169 179
170 my $part = shift @selector; 180 my $part = shift @selector;
181
182 # if this rule doesn't have a selector
183 next unless $part;
171 184
172 if ($part->{any}) { 185 if ($part->{any}) {
173 #keep the rule for the next try 186 #keep the rule for the next try
174 push @next, $rule; 187 push @next, $rule;
175 188
176 $part = shift @selector while $part->{any}; 189 $part = shift @selector while $part->{any};
177 } 190 }
178
179 # if this rule doesn't have a selector
180 next unless $part;
181 191
182 my $newRule = { 192 my $newRule = {
183 selector => \@selector, 193 selector => \@selector,
184 data => $rule->{data}, 194 data => $rule->{data},
185 weight => $rule->{weight}, 195 weight => $rule->{weight},