annotate Lib/IMPL/Web/Handler/TTView.pm @ 204:d63f9a92d6d4

+IMPL::Config::Include - simple way to include external config *IMPL::Web::Handler::TTView - finished template selecting mechanism (not tested)
author sergey
date Wed, 02 May 2012 17:42:47 +0400
parents 68a59c3358ff
children 891c04080658
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
1 package IMPL::Web::Handler::TTView;
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
2 use strict;
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
3
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
4 use List::Util qw(first);
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
5 use IMPL::lang qw(:declare :constants);
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
6 use IMPL::declare {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
7 base => {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
8 'IMPL::Object' => undef,
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
9 'IMPL::Object::Autofill' => '@_',
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
10 'IMPL::Object::Serializable' => undef
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
11 }
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
12 };
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
13
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
14 BEGIN {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
15 public property contentType => PROP_GET | PROP_OWNERSET;
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
16 public property loader => PROP_GET | PROP_OWNERSET;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
17 public property selectors => PROP_GET | PROP_LIST | PROP_OWNERSET;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
18 public property defaultDocument => PROP_ALL;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
19 public property indexResource => PROP_ALL;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
20 private property _selectorsCache => PROP_ALL;
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
21 private property _classTemplates => PROP_ALL;
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
22 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
23
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
24 sub CTOR {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
25 my ($this) = @_;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
26
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
27 $this->indexResource('index') unless $this->indexResource;
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
28 }
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
29
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
30 sub Invoke {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
31 my ($this,$action,$next) = @_;
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
32
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
33 my $result = $next ? $next->($action) : undef;
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
34
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
35 my $doc = $this->loader->document(
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
36 $this->SelectView($action,ref $result),
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
37 {
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
38 data => $result,
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
39 action => $action,
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
40 app => $action->application
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
41 }
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
42 );
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
43
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
44 my $hout = $action->response->streamBody;
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
45
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
46 print $hout $doc->Render();
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
47 }
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
48
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
49 sub SelectView {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
50 my ($this,$action,$class) = @_;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
51
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
52 my @path = split /\//, $action->query->path_info(), -1;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
53
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
54 my $last = pop @path;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
55 $last =~ s/\.\w+$//;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
56 $last = $this->indexResource;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
57 push @path,$last;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
58
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
59 $this->BuildCache unless $this->_selectorsCache;
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
60 my $cache = $this->_selectorsCache;
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
61
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
62 foreach my $subclass ( $class ? (_GetHierarchy($class), '-default') : '-plain') {
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
63 my @results;
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
64 push @results, { data => $this->_classTemplates->{$subclass} } if $this->_classTemplates->{$subclass};
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
65 my $alternatives = [ { selectors => $cache->{$subclass}, immediate => 1 } ];
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
66 $alternatives = $this->MatchAlternatives($_,$alternatives,\@results) foreach @path;
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
67
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
68 if (@results) {
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
69 return shift sort { $b->{level} <=> $a->{level} } @results;
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
70 }
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
71 }
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
72
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
73 return $this->defaultDocument;
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
74 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
75
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
76 sub _GetHierarchy {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
77 my ($class) = @_;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
78 return unless $class;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
79
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
80 no strict 'refs';
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
81
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
82 return $class, map { _GetHierarchy($_) } @{"${class}::ISA"};
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
83 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
84
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
85 sub BuildCache {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
86 my ($this) = @_;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
87
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
88 my @selectors;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
89
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
90 my $cache = $this->_selectorsCache({});
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
91 $this->_classTemplates({});
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
92
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
93 foreach my $selector ($this->selectors) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
94 if (not ref $selector) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
95
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
96 my ($path,$data) = split(/\s*=>\s*/, $selector);
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
97
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
98 my @path = split(/\s+/,$path);
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
99
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
100 my $class;
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
101
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
102 # if this selector has a class part
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
103 if ($path[$#path-1] =~ m/^\@(.*)/) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
104 $class = $1;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
105 shift @path;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
106 } else {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
107 $class = '-default';
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
108 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
109
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
110 #if this selector has a path
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
111 if (@path) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
112 @path = reverse @path;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
113 my $last = pop @path;
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
114 my $t = ( $cache->{$class} ||= {} );
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
115 my $level = 1;
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
116 foreach my $prim (@path ) {
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
117 $t = ($t->{$prim}->{next} ||= {});
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
118 $level ++;
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
119 }
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
120 $t->{$last}->{level} = $level;
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
121 $t->{$last}->{data} = $data;
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
122
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
123 } else {
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
124 # we dont have a selector, only class
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
125
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
126 $this->_classTemplates->{$class} = $data;
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
127 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
128
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
129 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
130 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
131 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
132
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
133 sub MatchAlternatives {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
134 my ($this,$segment,$alternatives,$results) = @_;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
135
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
136 warn "alternatives: ", scalar @$alternatives,", segment: $segment";
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
137
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
138 my @next;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
139
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
140 foreach my $alt (@$alternatives) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
141 while (my ($selector,$match) = each %{$alt->{selector}} ) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
142 warn $selector;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
143
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
144 warn "\timmediate" if $alt->{immediate};
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
145 warn "\thas children" if $match->{next};
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
146
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
147 my $context = {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
148 vars => \%{ $alt->{vars} || {} },
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
149 selector => $match->{next}
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
150 };
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
151
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
152 if ($selector =~ s/^>//) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
153 $context->{immediate} = 1;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
154 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
155
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
156 if (my ($name,$rx) = ($selector =~ m/^\{(?:(\w+)\:)?(.*)\}$/) ) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
157 #this is a regexp
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
158 warn "\tregexp: [$name] $rx";
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
159
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
160 if ( my @captures = ($segment =~ m/($rx)/) ) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
161 $context->{success} = 1;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
162
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
163 warn "\t",join(',',@captures);
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
164
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
165 if ($name) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
166 $context->{vars}->{$name} = \@captures;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
167 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
168 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
169 } else {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
170 #this is a segment name
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
171 if ($segment eq $selector) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
172 $context->{success} = 1;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
173 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
174 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
175
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
176 # test if there were a match
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
177 if (delete $context->{success}) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
178 warn "\tmatch";
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
179 if (my $data = $match->{data}) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
180 # interpolate data
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
181 $data =~ s/{(\w+)(?:\:(\d+))?}/
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
182 my ($name,$index) = ($1,$2 || 0);
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
183
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
184 if ($context->{vars}{$name}) {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
185 $context->{vars}{$name}[$index];
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
186 } else {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
187 "";
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
188 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
189 /gex;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
190
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
191 push @$results, { level => $match->{level}, result => $data };
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
192 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
193 warn "\tnext" if $context->{selector};
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
194 push @next, $context if $context->{selector};
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
195 } else {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
196 #repeat current alternative if it's not required to be immediate
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
197 push @next, {
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
198 selector => { $selector, $match },
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
199 vars => $alt->{vars}
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
200 } unless $alt->{immediate};
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
201 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
202 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
203 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
204
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
205 warn "end, next trip: ",scalar @next, " alternatives";
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
206
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
207 return \@next;
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
208 }
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
209
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
210 1;
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
211
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
212 __END__
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
213
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
214 =pod
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
215
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
216 =head1 NAME
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
217
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
218 C<IMPL::Web::Handler::TTView> - использует шаблоны для построения представления.
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
219
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
220 =head1 SYNOPSIS
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
221
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
222 =begin code xml
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
223
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
224 <view type="HASH">
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
225 <item extname="@My::Data::Product">product/info</item>
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
226 <catalog>
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
227 <catalog>
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
228 </view>
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
229
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
230 =end code xml
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
231
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
232 =head1 DESCRIPTION
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
233
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
234 Подбирает шаблон для представления результата, полученного при выполнении следующего обработчика. При
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
235 выборе используется принцип похожий на селекторы C<CSS>, основывающийся на именах ресурсов и их типах
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
236 данных.
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
237
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
238 =head1 SELECTORS
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
239
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
240 =begin text
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
241
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
242 [url-template] [class] => template
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
243
200
sergey
parents: 199
diff changeset
244 shoes * => product/list
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
245 {action:*.} @My::Data::Product => product/{action}
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
246
204
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
247 stuff list => product/list
d63f9a92d6d4 +IMPL::Config::Include - simple way to include external config
sergey
parents: 203
diff changeset
248 details => product/details
203
68a59c3358ff Implemented templates selection mechanism
sergey
parents: 200
diff changeset
249
199
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
250 =end text
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
251
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
252
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
253 =cut
e743a8481327 Added REST support for forms (with only get and post methods)
sergey
parents:
diff changeset
254