prepared release
[catagits/CatalystX-Declare.git] / README
CommitLineData
a1c42bd6 1NAME
2 CatalystX::Declare - EXPERIMENTAL Declarative Syntax for Catalyst
3 Applications
4
5SYNOPSIS
6 Application
7 use CatalystX::Declare;
8
9 application MyApp::Web with Static::Simple {
10
11 $CLASS->config(name => 'My Declarative Web Application');
12 }
13
fbb4c5ce 14 See also: CatalystX::Declare::Keyword::Application, "class" in
15 MooseX::Declare
16
a1c42bd6 17 Controllers
18 use CatalystX::Declare;
19
20 controller MyApp::Web::Controller::Foo
21 with MyApp::Web::ControllerRole::Bar {
22
23 use MooseX::Types::Moose qw( Str );
24
25
26 has welcome_message => (
27 is => 'rw',
28 isa => Str,
29 required => 1,
30 lazy_build => 1,
31 );
32
33 method _build_welcome_message { 'Welcome' }
34
35
eebffd0a 36 action base under '/' as '';
a1c42bd6 37
38 under base {
39
40 final action welcome {
41 $ctx->response->body( $self->welcome_message );
42 }
43 }
44 }
45
fbb4c5ce 46 See also: CatalystX::Declare::Keyword::Controller,
47 CatalystX::Declare::Keyword::Action,
48 CatalystX::Declare::Keyword::Component, "class" in MooseX::Declare
49
a1c42bd6 50 Roles
51 use CatalystX::Declare;
52
8e5d9092 53 controller_role MyApp::Web::ControllerRole::Bar {
a1c42bd6 54
55 use MyApp::Types qw( Username );
56
57
58 around _build_welcome_message { $self->$orig . '!' }
59
60 after welcome (Object $ctx) {
61
62 $ctx->response->body(join "\n",
63 $ctx->response->body,
64 time(),
65 );
66 }
67
68
69 final action special_welcome (Username $name) under base {
70
71 $ctx->response->body('Hugs to ' . $name);
72 }
73 }
74
fbb4c5ce 75 See also: CatalystX::Declare::Keyword::Role,
76 CatalystX::Declare::Keyword::Action, "class" in MooseX::Declare
77
78 Views
79 use CatalystX::Declare;
80
81 view MyApp::Web::View::TT
82 extends Catalyst::View::TT {
83
84 $CLASS->config(
85 TEMPLATE_EXTENSION => '.html',
86 );
87 }
88
89 See also: CatalystX::Declare::Keyword::View,
90 CatalystX::Declare::Keyword::Component, "class" in MooseX::Declare
91
92 Models
93 use CatalystX::Declare;
94
95 model MyApp::Web::Model::DBIC::Schema
96 extends Catalyst::Model::DBIC::Schema {
97
98 $CLASS->config(
99 schema_class => 'MyApp::Schema',
100 );
101 }
102
103 See also: CatalystX::Declare::Keyword::Model,
104 CatalystX::Declare::Keyword::Component, "class" in MooseX::Declare
105
a1c42bd6 106DESCRIPTION
eebffd0a 107 This module is EXPERIMENTAL
108
a1c42bd6 109 This module provides a declarative syntax for Catalyst applications. Its
110 main focus is currently on common and repetitious parts of the
111 application, such as the application class itself, controllers, and
112 controller roles.
113
114 Not a Source Filter
115 The used syntax elements are not parsed via source filter mechanism, but
116 through Devel::Declare, which is a much less fragile deal to handle and
117 allows extensions to mix without problems. For example, all keywords
118 added by this module are separete handlers.
119
120 Syntax Documentation
121 The documentation about syntax is in the respective parts of the
122 distribution below the "CatalystX::Declare::Keyword::" namespace. Here
123 are the manual pages you will be interested in to familiarize yourself
124 with this module's syntax extensions:
125
126 CatalystX::Declare::Keyword::Application
a1c42bd6 127 CatalystX::Declare::Keyword::Action
fbb4c5ce 128 CatalystX::Declare::Keyword::Controller
a1c42bd6 129 CatalystX::Declare::Keyword::Role
fbb4c5ce 130 CatalystX::Declare::Keyword::View
131 CatalystX::Declare::Keyword::Model
a1c42bd6 132
133 Things like models, views, roles for request or response objects, can be
134 built declaratively with MooseX::Declare, which is used to additionally
135 provide keywords for "class", "role", "method" and the available method
136 modifier declarations. This allows for constructs such as:
137
138 use CatalystX::Declare;
139
140 class Foo {
141
142 method bar { 23 }
143 }
144
145 controller MyApp::Web::Controller::Baz {
146
eebffd0a 147 final action qux under '/' {
a1c42bd6 148 $ctx->response->body(Foo->new->bar)
149 }
150 }
151
152SEE ALSO
153 For Usage Information
154 These links are intended for the common user of this module.
155
156 Catalyst::Runtime
157 Catalyst::Devel
158 Catalyst::Manual
159 Although you probably already know Catalyst, since you otherwise
160 probably wouldn't be here, I include these links for completeness
161 sake.
162
163 Moose
164 The powerful modern Perl object orientation implementation that is
165 used as basis for Catalyst. MooseX::Declare, on which
166 CatalystX::Declare is based, provides a declarative syntax for
167 Moose.
168
169 MooseX::Declare
170 We inherit almost all functionality from MooseX::Declare to allow
171 the declaration of traditional classes, roles, methods, modifiers,
172 etc. Refer to this documentation first for syntax elements that
173 aren't part of CatalystX::Declare.
174
175 MooseX::Method::Signatures
176 This isn't directly used, but MooseX::Declare utilises this to
177 provide us with method and modifier declarations. For extended
178 information on the usage of methods, especially signatures, refer to
179 this module after looking for an answer in the MooseX::Declare
180 documentation.
181
182 For Developer Information
183 This section contains links relevant to the implementation of this
184 module.
185
186 Devel::Declare
187 You could call this is the basic machine room that runs the
188 interaction with perl. It provides a way to hook into perl's source
189 code parsing and change small parts on a per-statement basis.
190
191 MooseX::MethodAttributes
192 We use this module to easily communicate the action attributes to
193 Catalyst. Currently, this is the easiest solution for now but may be
194 subject to change in the future.
195
196AUTHOR
197 Robert 'phaylon' Sedlacek, <rs@474.at>
198
199 With contributions from, and many thanks to:
200
201 Florian Ragwitz
202 John Napiorkowski
203
204LICENSE
205 This program is free software; you can redistribute it and/or modify it
206 under the same terms as perl itself.
207