3 class CatalystX::Declare extends MooseX::Declare is dirty {
5 use aliased 'CatalystX::Declare::Keyword::Controller', 'ControllerKeyword';
6 use aliased 'CatalystX::Declare::Keyword::Role', 'RoleKeyword';
7 use aliased 'CatalystX::Declare::Keyword::Application', 'ApplicationKeyword';
11 our $VERSION = '0.003';
15 ControllerKeyword->new(identifier => 'controller'),
16 RoleKeyword->new(identifier => 'component_role'),
17 ApplicationKeyword->new(identifier => 'application'),
25 CatalystX::Declare - EXPERIMENTAL Declarative Syntax for Catalyst Applications
31 use CatalystX::Declare;
33 application MyApp::Web with Static::Simple {
35 $CLASS->config(name => 'My Declarative Web Application');
40 use CatalystX::Declare;
42 controller MyApp::Web::Controller::Foo
43 with MyApp::Web::ControllerRole::Bar {
45 use MooseX::Types::Moose qw( Str );
48 has welcome_message => (
55 method _build_welcome_message { 'Welcome' }
58 action base under '/' as '';
62 final action welcome {
63 $ctx->response->body( $self->welcome_message );
70 use CatalystX::Declare;
72 component_role MyApp::Web::ControllerRole::Bar {
74 use MyApp::Types qw( Username );
77 around _build_welcome_message { $self->$orig . '!' }
79 after welcome (Object $ctx) {
81 $ctx->response->body(join "\n",
88 final action special_welcome (Username $name) under base {
90 $ctx->response->body('Hugs to ' . $name);
96 B<This module is EXPERIMENTAL>
98 This module provides a declarative syntax for L<Catalyst|Catalyst::Runtime>
99 applications. Its main focus is currently on common and repetitious parts of
100 the application, such as the application class itself, controllers, and
103 =head2 Not a Source Filter
105 The used syntax elements are not parsed via source filter mechanism, but
106 through L<Devel::Declare>, which is a much less fragile deal to handle and
107 allows extensions to mix without problems. For example, all keywords added
108 by this module are separete handlers.
110 =head2 Syntax Documentation
112 The documentation about syntax is in the respective parts of the distribution
113 below the C<CatalystX::Declare::Keyword::> namespace. Here are the manual
114 pages you will be interested in to familiarize yourself with this module's
119 =item L<CatalystX::Declare::Keyword::Application>
121 =item L<CatalystX::Declare::Keyword::Controller>
123 =item L<CatalystX::Declare::Keyword::Action>
125 =item L<CatalystX::Declare::Keyword::Role>
129 Things like models, views, roles for request or response objects, can be built
130 declaratively with L<MooseX::Declare>, which is used to additionally provide
131 keywords for C<class>, C<role>, C<method> and the available method modifier
132 declarations. This allows for constructs such as:
134 use CatalystX::Declare;
141 controller MyApp::Web::Controller::Baz {
143 final action qux under '/' {
144 $ctx->response->body(Foo->new->bar)
150 =head2 For Usage Information
152 These links are intended for the common user of this module.
156 =item L<Catalyst::Runtime>
158 =item L<Catalyst::Devel>
160 =item L<Catalyst::Manual>
162 Although you probably already know Catalyst, since you otherwise probably
163 wouldn't be here, I include these links for completeness sake.
167 The powerful modern Perl object orientation implementation that is used
168 as basis for Catalyst. L<MooseX::Declare>, on which L<CatalystX::Declare>
169 is based, provides a declarative syntax for L<Moose>.
171 =item L<MooseX::Declare>
173 We inherit almost all functionality from L<MooseX::Declare> to allow the
174 declaration of traditional classes, roles, methods, modifiers, etc. Refer
175 to this documentation first for syntax elements that aren't part of
176 L<CatalystX::Declare>.
178 =item L<MooseX::Method::Signatures>
180 This isn't directly used, but L<MooseX::Declare> utilises this to provide
181 us with method and modifier declarations. For extended information on the
182 usage of methods, especially signatures, refer to this module after
183 looking for an answer in the L<MooseX::Declare> documentation.
187 =head2 For Developer Information
189 This section contains links relevant to the implementation of this module.
193 =item L<Devel::Declare>
195 You could call this is the basic machine room that runs the interaction with
196 perl. It provides a way to hook into perl's source code parsing and change
197 small parts on a per-statement basis.
199 =item L<MooseX::MethodAttributes>
201 We use this module to easily communicate the action attributes to
202 L<Catalyst|Catalyst::Runtime>. Currently, this is the easiest solution for
203 now but may be subject to change in the future.
212 =item Robert 'phaylon' Sedlacek, L<E<lt>rs@474.atE<gt>>
216 With contributions from, and many thanks to:
220 =item Florian Ragwitz
222 =item John Napiorkowski
229 This program is free software; you can redistribute it and/or modify it under
230 the same terms as perl itself.