annotate Lib/IMPL/Web/Handler/TTView.pm @ 203:68a59c3358ff

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