3 class CatalystX::Declare extends MooseX::Declare is dirty {
5 use aliased 'CatalystX::Declare::Keyword::Model', 'ModelKeyword';
6 use aliased 'CatalystX::Declare::Keyword::View', 'ViewKeyword';
7 use aliased 'CatalystX::Declare::Keyword::Controller', 'ControllerKeyword';
8 use aliased 'CatalystX::Declare::Keyword::Role', 'RoleKeyword';
9 use aliased 'CatalystX::Declare::Keyword::Application', 'ApplicationKeyword';
13 our $VERSION = '0.012';
15 around keywords (ClassName $self:) {
17 ControllerKeyword->new( identifier => 'controller' ),
18 RoleKeyword->new( identifier => 'controller_role' ),
19 ApplicationKeyword->new( identifier => 'application' ),
20 ViewKeyword->new( identifier => 'view' ),
21 ModelKeyword->new( identifier => 'model' ),
29 CatalystX::Declare - EXPERIMENTAL Declarative Syntax for Catalyst Applications
35 use CatalystX::Declare;
37 application MyApp::Web with Static::Simple {
39 $CLASS->config(name => 'My Declarative Web Application');
43 L<CatalystX::Declare::Keyword::Application>,
44 L<MooseX::Declare/class>
48 use CatalystX::Declare;
50 controller MyApp::Web::Controller::Foo
51 with MyApp::Web::ControllerRole::Bar {
53 use MooseX::Types::Moose qw( Str );
56 has welcome_message => (
63 method _build_welcome_message { 'Welcome' }
66 action base under '/' as '';
70 final action welcome {
71 $ctx->response->body( $self->welcome_message );
77 L<CatalystX::Declare::Keyword::Controller>,
78 L<CatalystX::Declare::Keyword::Action>,
79 L<CatalystX::Declare::Keyword::Component>,
80 L<MooseX::Declare/class>
84 use CatalystX::Declare;
86 controller_role MyApp::Web::ControllerRole::Bar {
88 use MyApp::Types qw( Username );
91 around _build_welcome_message { $self->$orig . '!' }
93 after welcome (Object $ctx) {
95 $ctx->response->body(join "\n",
102 final action special_welcome (Username $name) under base {
104 $ctx->response->body('Hugs to ' . $name);
109 L<CatalystX::Declare::Keyword::Role>,
110 L<CatalystX::Declare::Keyword::Action>,
111 L<MooseX::Declare/class>
115 use CatalystX::Declare;
117 view MyApp::Web::View::TT
118 extends Catalyst::View::TT {
121 TEMPLATE_EXTENSION => '.html',
126 L<CatalystX::Declare::Keyword::View>,
127 L<CatalystX::Declare::Keyword::Component>,
128 L<MooseX::Declare/class>
132 use CatalystX::Declare;
134 model MyApp::Web::Model::DBIC::Schema
135 extends Catalyst::Model::DBIC::Schema {
138 schema_class => 'MyApp::Schema',
143 L<CatalystX::Declare::Keyword::Model>,
144 L<CatalystX::Declare::Keyword::Component>,
145 L<MooseX::Declare/class>
149 B<This module is EXPERIMENTAL>
151 This module provides a declarative syntax for L<Catalyst|Catalyst::Runtime>
152 applications. Its main focus is currently on common and repetitious parts of
153 the application, such as the application class itself, controllers, and
156 =head2 Not a Source Filter
158 The used syntax elements are not parsed via source filter mechanism, but
159 through L<Devel::Declare>, which is a much less fragile deal to handle and
160 allows extensions to mix without problems. For example, all keywords added
161 by this module are separete handlers.
163 =head2 Syntax Documentation
165 The documentation about syntax is in the respective parts of the distribution
166 below the C<CatalystX::Declare::Keyword::> namespace. Here are the manual
167 pages you will be interested in to familiarize yourself with this module's
172 =item L<CatalystX::Declare::Keyword::Application>
174 =item L<CatalystX::Declare::Keyword::Action>
176 =item L<CatalystX::Declare::Keyword::Controller>
178 =item L<CatalystX::Declare::Keyword::Role>
180 =item L<CatalystX::Declare::Keyword::View>
182 =item L<CatalystX::Declare::Keyword::Model>
186 Things like models, views, roles for request or response objects, can be built
187 declaratively with L<MooseX::Declare>, which is used to additionally provide
188 keywords for C<class>, C<role>, C<method> and the available method modifier
189 declarations. This allows for constructs such as:
191 use CatalystX::Declare;
198 controller MyApp::Web::Controller::Baz {
200 final action qux under '/' {
201 $ctx->response->body(Foo->new->bar)
207 =head2 For Usage Information
209 These links are intended for the common user of this module.
213 =item L<Catalyst::Runtime>
215 =item L<Catalyst::Devel>
217 =item L<Catalyst::Manual>
219 Although you probably already know Catalyst, since you otherwise probably
220 wouldn't be here, I include these links for completeness sake.
224 The powerful modern Perl object orientation implementation that is used
225 as basis for Catalyst. L<MooseX::Declare>, on which L<CatalystX::Declare>
226 is based, provides a declarative syntax for L<Moose>.
228 =item L<MooseX::Declare>
230 We inherit almost all functionality from L<MooseX::Declare> to allow the
231 declaration of traditional classes, roles, methods, modifiers, etc. Refer
232 to this documentation first for syntax elements that aren't part of
233 L<CatalystX::Declare>.
235 =item L<MooseX::Method::Signatures>
237 This isn't directly used, but L<MooseX::Declare> utilises this to provide
238 us with method and modifier declarations. For extended information on the
239 usage of methods, especially signatures, refer to this module after
240 looking for an answer in the L<MooseX::Declare> documentation.
244 =head2 For Developer Information
246 This section contains links relevant to the implementation of this module.
250 =item L<Devel::Declare>
252 You could call this is the basic machine room that runs the interaction with
253 perl. It provides a way to hook into perl's source code parsing and change
254 small parts on a per-statement basis.
256 =item L<MooseX::MethodAttributes>
258 We use this module to easily communicate the action attributes to
259 L<Catalyst|Catalyst::Runtime>. Currently, this is the easiest solution for
260 now but may be subject to change in the future.
269 =item Robert 'phaylon' Sedlacek, L<E<lt>rs@474.atE<gt>>
273 With contributions from, and many thanks to:
277 =item Florian Ragwitz
279 =item John Napiorkowski
286 This program is free software; you can redistribute it and/or modify it under
287 the same terms as perl itself.