Mercurial > pub > Impl
annotate Lib/IMPL/Web/Handler/View.pm @ 353:feeb3bc4a818
corrected error handling while loading templates
corrected variables lookup in controls
updated handles to use the new view features
| author | cin | 
|---|---|
| date | Fri, 11 Oct 2013 15:49:04 +0400 | 
| parents | Lib/IMPL/Web/Handler/TTView.pm@97628101b765 | 
| children | 9330835535b9 | 
| rev | line source | 
|---|---|
| 353 | 1 package IMPL::Web::Handler::View; | 
| 
199
 
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 | 
| 291 | 4 use Carp qw(carp); | 
| 
204
 
d63f9a92d6d4
+IMPL::Config::Include - simple way to include external config
 
sergey 
parents: 
203 
diff
changeset
 | 
5 use List::Util qw(first); | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
6 use IMPL::lang; | 
| 233 | 7 use IMPL::Const qw(:prop); | 
| 
199
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
8 use IMPL::declare { | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
9 require => { | 
| 
240
 
abc7c26bf615
+Added ObjectFactory for templates with static members support
 
sergey 
parents: 
235 
diff
changeset
 | 
10 Factory => 'IMPL::Web::View::ObjectFactory', | 
| 
241
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
11 HttpResponse => 'IMPL::Web::HttpResponse', | 
| 
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
12 Loader => 'IMPL::Code::Loader', | 
| 
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
13 ViewResult => '-IMPL::Web::ViewResult' | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
14 }, | 
| 
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
15 base => [ | 
| 
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
16 'IMPL::Object' => undef, | 
| 
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
17 'IMPL::Object::Autofill' => '@_', | 
| 
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
18 'IMPL::Object::Serializable' => undef | 
| 
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
19 ], | 
| 
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
20 | 
| 
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
21 props => [ | 
| 233 | 22 contentType => PROP_RO, | 
| 23 contentCharset => PROP_RO, | |
| 353 | 24 view => PROP_RO, | 
| 25 layout => PROP_RO, | |
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
26 selectors => PROP_RO, | 
| 233 | 27 defaultDocument => PROP_RW, | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
28 _selectorsCache => PROP_RW | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
29 ] | 
| 
199
 
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 | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
32 sub CTOR { | 
| 
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
33 my ($this) = @_; | 
| 203 | 34 | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
35 $this->_selectorsCache([ map $this->ParseRule($_), @{$this->selectors || []} ]); | 
| 
199
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
36 } | 
| 
 
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 sub Invoke { | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
39 my ( $this, $action, $next ) = @_; | 
| 
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
40 | 
| 
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
41 my $result = $next ? $next->($action) : undef; | 
| 
241
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
42 | 
| 353 | 43 my ($model,$view,$template); | 
| 
241
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
44 if( ref $result and eval { $result->isa(ViewResult) } ) { | 
| 
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
45 $model = $result->model; | 
| 353 | 46 $view = $result; | 
| 47 $template = $result->template; | |
| 
241
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
48 } else { | 
| 
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
49 $model = $result; | 
| 
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
50 $view = ViewResult->new(model => $model); | 
| 
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
51 } | 
| 
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
52 | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
53 my $vars = { | 
| 
241
 
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
 
sergey 
parents: 
240 
diff
changeset
 | 
54 view => $view, | 
| 
339
 
97628101b765
refactoring: application now holds a security object factory rather than a security object
 
cin 
parents: 
334 
diff
changeset
 | 
55 request => sub { $action }, | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
56 app => $action->application, | 
| 334 | 57 context => $action->context, | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
58 env => _cached($action->context->{environment}), | 
| 353 | 59 location => $action->context->{resourceLocation}, | 
| 60 layout => $this->layout | |
| 61 }; | |
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
62 | 
| 353 | 63 $this->view->display( | 
| 64 $model, | |
| 65 $template || $this->SelectView( $action, ref $model ), | |
| 66 $vars | |
| 67 ); | |
| 
256
 
32aceba4ee6d
corrected ViewHandlers to handle cookies and headers.
 
sergey 
parents: 
244 
diff
changeset
 | 
68 | 
| 
 
32aceba4ee6d
corrected ViewHandlers to handle cookies and headers.
 
sergey 
parents: 
244 
diff
changeset
 | 
69 my %responseParams = ( | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
70 type => $this->contentType, | 
| 
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
71 charset => $this->contentCharset, | 
| 353 | 72 body => $this->view->display( | 
| 73 $model, | |
| 74 $template || $this->SelectView( $action, ref $model ), | |
| 75 $vars | |
| 76 ) | |
| 
199
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
77 ); | 
| 
256
 
32aceba4ee6d
corrected ViewHandlers to handle cookies and headers.
 
sergey 
parents: 
244 
diff
changeset
 | 
78 | 
| 
 
32aceba4ee6d
corrected ViewHandlers to handle cookies and headers.
 
sergey 
parents: 
244 
diff
changeset
 | 
79 $responseParams{status} = $view->status if $view->status; | 
| 
 
32aceba4ee6d
corrected ViewHandlers to handle cookies and headers.
 
sergey 
parents: 
244 
diff
changeset
 | 
80 $responseParams{cookies} = $view->cookies if ref $view->cookies eq 'HASH'; | 
| 
 
32aceba4ee6d
corrected ViewHandlers to handle cookies and headers.
 
sergey 
parents: 
244 
diff
changeset
 | 
81 $responseParams{headers} = $view->headers if ref $view->headers eq 'HASH'; | 
| 
 
32aceba4ee6d
corrected ViewHandlers to handle cookies and headers.
 
sergey 
parents: 
244 
diff
changeset
 | 
82 | 
| 
 
32aceba4ee6d
corrected ViewHandlers to handle cookies and headers.
 
sergey 
parents: 
244 
diff
changeset
 | 
83 return HttpResponse->new( | 
| 
 
32aceba4ee6d
corrected ViewHandlers to handle cookies and headers.
 
sergey 
parents: 
244 
diff
changeset
 | 
84 %responseParams | 
| 
 
32aceba4ee6d
corrected ViewHandlers to handle cookies and headers.
 
sergey 
parents: 
244 
diff
changeset
 | 
85 ); | 
| 
199
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
86 } | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
87 | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
88 sub _cached { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
89 my $arg = shift; | 
| 
266
 
89179bb8c388
*corrected TTView to handle plain (and undefined) values
 
cin 
parents: 
256 
diff
changeset
 | 
90 | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
91 return $arg unless ref $arg eq 'CODE'; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
92 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
93 return sub { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
94 ref $arg eq 'CODE' ? $arg = &$arg() : $arg; | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
95 } | 
| 203 | 96 } | 
| 97 | |
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
98 sub SelectView { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
99 my ($this,$action) = @_; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
100 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
101 my @path; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
102 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
103 for(my $r = $action->context->{resource}; $r ; $r = $r->parent ) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
104 unshift @path, { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
105 name => $r->id, | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
106 class => typeof($r->model) | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
107 }; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
108 } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
109 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
110 @path = map { name => $_}, split /\/+/, $action->query->path_info() | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
111 unless (@path); | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
112 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
113 return $this->MatchPath(\@path,$this->_selectorsCache) || $this->defaultDocument; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
114 } | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
115 | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
116 sub ParseRule { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
117 my ($this, $rule) = @_; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
118 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
119 my ($selector,$data) = split /\s+=>\s+/, $rule; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
120 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
121 my @parts; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
122 my $first = 1; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
123 my $weight = 0; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
124 foreach my $part ( split /\//, $selector ) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
125 # если первым символом является / | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
126 # значит путь в селекторе абсолютный и не нужно | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
127 # добавлять "любой" элемент в начало | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
128 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
129 if($part) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
130 $weight ++; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
131 push @parts,{ any => 1 } if $first; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
132 } else { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
133 push @parts,{ any => 1 } unless $first; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
134 next; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
135 } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
136 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
137 my ($name,$class) = split /@/, $part; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
138 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
139 if ( my ( $varName, $rx ) = ( $name =~ m/^\{(?:(\w+)\:)?(.*)\}$/ ) ) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
140 #this is a regexp | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
141 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
142 push @parts, { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
143 rx => $rx, | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
144 var => $varName, | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
145 class => $class, | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
146 }; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
147 } else { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
148 push @parts, { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
149 name => length($name) ? $name : undef, | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
150 class => $class, | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
151 }; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
152 } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
153 } continue { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
154 $first = 0; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
155 } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
156 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
157 return { selector => \@parts, data => $data, weight => $weight }; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
158 } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
159 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
160 sub MatchPath { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
161 my ($this,$path,$rules) = @_; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
162 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
163 $path ||= []; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
164 $rules ||= []; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
165 | 
| 203 | 166 my @next; | 
| 
266
 
89179bb8c388
*corrected TTView to handle plain (and undefined) values
 
cin 
parents: 
256 
diff
changeset
 | 
167 | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
168 foreach my $segment (@$path) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
169 foreach my $rule (@$rules) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
170 my @selector = @{$rule->{selector}}; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
171 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
172 my $part = shift @selector; | 
| 291 | 173 | 
| 174 # if this rule doesn't have a selector | |
| 175 next unless $part; | |
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
176 | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
177 if ($part->{any}) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
178 #keep the rule for the next try | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
179 push @next, $rule; | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
180 | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
181 $part = shift @selector while $part->{any}; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
182 } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
183 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
184 my $newRule = { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
185 selector => \@selector, | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
186 data => $rule->{data}, | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
187 weight => $rule->{weight}, | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
188 vars => { %{$rule->{vars} || {}} } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
189 }; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
190 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
191 my $success = 1; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
192 if (my $class = $part->{class}) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
193 $success = isclass($segment->{class},$class); | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
194 } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
195 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
196 if($success && (my $name = $part->{name})) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
197 $success = $segment->{name} eq $name; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
198 } elsif ($success && (my $rx = $part->{rx})) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
199 if( my @captures = ($segment->{name} =~ m/($rx)/) ) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
200 $newRule->{vars}->{$part->{var}} = \@captures | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
201 if $part->{var}; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
202 } else { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
203 $success = 0; | 
| 203 | 204 } | 
| 
229
 
47f77e6409f7
heavily reworked the resource model of the web application:
 
sergey 
parents: 
206 
diff
changeset
 | 
205 } | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
206 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
207 push @next, $newRule if $success; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
208 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
209 } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
210 $rules = [@next]; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
211 undef @next; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
212 } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
213 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
214 my $result = ( | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
215 sort { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
216 $b->{weight} <=> $a->{weight} | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
217 } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
218 grep { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
219 scalar(@{$_->{selector}}) == 0 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
220 } | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
221 @$rules | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
222 )[0]; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
223 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
224 if($result) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
225 my $data = $result->{data}; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
226 $data =~ s/{(\w+)(?:\:(\d+))?}/ | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
227 my ($name,$index) = ($1,$2 || 0); | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
228 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
229 if ($result->{vars}{$name}) { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
230 $result->{vars}{$name}[$index]; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
231 } else { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
232 ""; | 
| 203 | 233 } | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
234 /gex; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
235 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
236 return $data; | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
237 } else { | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
238 return; | 
| 203 | 239 } | 
| 240 } | |
| 241 | |
| 
199
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
242 1; | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
243 | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
244 __END__ | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
245 | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
246 =pod | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
247 | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
248 =head1 NAME | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
249 | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
250 C<IMPL::Web::Handler::TTView> - использует шаблоны для построения представления. | 
| 
 
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 =head1 SYNOPSIS | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
253 | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
254 =begin code xml | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
255 | 
| 353 | 256 <item id="html-view" type="IMPL::Web::Handler::View"> | 
| 206 | 257 <contentType>text/html</contentType> | 
| 353 | 258 <view id="tt-loader" type="IMPL::Web::View::TTView"> | 
| 206 | 259 <options type="HASH"> | 
| 260 <INCLUDE_PATH type="IMPL::Config::Reference"> | |
| 261 <target>IMPL::Config</target> | |
| 262 <AppBase>view</AppBase> | |
| 263 </INCLUDE_PATH> | |
| 264 <INTERPOLATE>1</INTERPOLATE> | |
| 265 <POST_CHOMP>1</POST_CHOMP> | |
| 266 <ENCODING>utf-8</ENCODING> | |
| 267 </options> | |
| 268 <ext>.tt</ext> | |
| 269 <initializer>global.tt</initializer> | |
| 270 <layoutBase>layouts</layoutBase> | |
| 353 | 271 </view> | 
| 206 | 272 <defaultDocument>default</defaultDocument> | 
| 273 <selectors type="ARRAY"> | |
| 274 <item>@HASH => dump</item> | |
| 275 <item>@My::Data::Product => product/info</item> | |
| 276 <item>{action:.*} @My::Data::Product => product/{action}</item> | |
| 277 </selectors> | |
| 278 </item> | |
| 
199
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
279 | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
280 =end code xml | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
281 | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
282 =head1 DESCRIPTION | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
283 | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
284 Подбирает шаблон для представления результата, полученного при выполнении следующего обработчика. При | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
285 выборе используется принцип похожий на селекторы C<CSS>, основывающийся на именах ресурсов и их типах | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
286 данных. | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
287 | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
288 Данный обработчик понимает определенные свойства контекста: | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
289 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
290 =over | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
291 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
292 =item * C<resourceLocation> | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
293 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
294 В данном свойстве может быть передана информация о текущем расположении ресурса, | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
295 для которого строится представление. Эта информация будет доступна в шаблоне | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
296 через свойство документа C<location>. | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
297 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
298 =item * C<environment> | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
299 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
300 В данном совойстве контекста передается дополнительная информация об окружении | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
301 ресурса, например, которую задали родительские ресурсы. Использование данного | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
302 свойства позволяет не загромождать ресурс реализацией функциональности по | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
303 поддержке окружения. Это свойство может быть ссылкой на функцию, что позволяет | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
304 формировать контекст только по необходимости, при этом указанная функция будет | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
305 выполнена только один раз, при первом обращении. | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
306 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
307 =back | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
308 | 
| 
199
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
309 =head1 SELECTORS | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
310 | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
311 =begin text | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
312 | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
313 syntax::= selector => template | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
314 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
315 selector::= ([>]segment-template[@class-name]) | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
316 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
317 segment-template::= {'{'name:regular-expr'}'|segment-name} | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
318 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
319 name::= \w+ | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
320 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
321 segment-name::= \S+ | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
322 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
323 class-name::= name[(::name)] | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
324 | 
| 
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
325 url-template@class => template | 
| 
199
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
326 | 
| 206 | 327 shoes => product/list | 
| 
285
 
546957c50a36
*IMPL::Web::Handler::TTView Reworked template selection mechanism
 
cin 
parents: 
281 
diff
changeset
 | 
328 /shop//{action:*.}@My::Data::Product => product/{action} | 
| 
199
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
329 | 
| 206 | 330 stuff >list => product/list | 
| 
204
 
d63f9a92d6d4
+IMPL::Config::Include - simple way to include external config
 
sergey 
parents: 
203 
diff
changeset
 | 
331 details => product/details | 
| 203 | 332 | 
| 
199
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
333 =end text | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
334 | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
335 | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
336 =cut | 
| 
 
e743a8481327
Added REST support for forms (with only get and post methods)
 
sergey 
parents:  
diff
changeset
 | 
337 | 
