Mercurial > pub > Impl
comparison Lib/IMPL/Web/Handler/TTView.pm @ 199:e743a8481327
Added REST support for forms (with only get and post methods)
author | sergey |
---|---|
date | Mon, 23 Apr 2012 01:36:52 +0400 |
parents | |
children | a9dbe534d236 |
comparison
equal
deleted
inserted
replaced
198:2ffe6f661605 | 199:e743a8481327 |
---|---|
1 package IMPL::Web::Handler::TTView; | |
2 use strict; | |
3 | |
4 use IMPL::lang qw(:declare :constants); | |
5 use IMPL::declare { | |
6 base => { | |
7 'IMPL::Object' => undef, | |
8 'IMPL::Object::Autofill' => '@_', | |
9 'IMPL::Object::Serializable' => undef | |
10 } | |
11 }; | |
12 | |
13 BEGIN { | |
14 public property contentType => PROP_GET | PROP_OWNERSET; | |
15 public property templates => PROP_GET | PROP_OWNERSET; | |
16 } | |
17 | |
18 sub Invoke { | |
19 my ($this,$action,$next) = @_; | |
20 | |
21 my $result = $next ? $next->($action) : undef; | |
22 | |
23 my $doc = $this->templates->document( | |
24 'default', | |
25 { | |
26 data => $result, | |
27 action => $action, | |
28 app => $action->application | |
29 } | |
30 ); | |
31 | |
32 my $hout = $action->response->streamBody; | |
33 | |
34 print $hout $doc->Render(); | |
35 } | |
36 | |
37 1; | |
38 | |
39 __END__ | |
40 | |
41 =pod | |
42 | |
43 =head1 NAME | |
44 | |
45 C<IMPL::Web::Handler::TTView> - использует шаблоны для построения представления. | |
46 | |
47 =head1 SYNOPSIS | |
48 | |
49 =begin code xml | |
50 | |
51 <view type="HASH"> | |
52 <item extname="@My::Data::Product">product/info</item> | |
53 <catalog> | |
54 <catalog> | |
55 </view> | |
56 | |
57 =end code xml | |
58 | |
59 =head1 DESCRIPTION | |
60 | |
61 Подбирает шаблон для представления результата, полученного при выполнении следующего обработчика. При | |
62 выборе используется принцип похожий на селекторы C<CSS>, основывающийся на именах ресурсов и их типах | |
63 данных. | |
64 | |
65 =head1 SELECTORS | |
66 | |
67 =begin text | |
68 | |
69 [url-template] [class] => template | |
70 | |
71 shoes/ => product/list | |
72 {action:*.} @My::Data::Product => product/{action} | |
73 | |
74 =end text | |
75 | |
76 | |
77 | |
78 =cut | |
79 |