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.001';
15 ControllerKeyword->new(identifier => 'controller'),
16 RoleKeyword->new(identifier => 'controller_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' }
62 final action welcome {
63 $ctx->response->body( $self->welcome_message );
70 use CatalystX::Declare;
72 controller_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 This module provides a declarative syntax for L<Catalyst|Catalyst::Runtime>
97 applications. Its main focus is currently on common and repetitious parts of
98 the application, such as the application class itself, controllers, and
101 =head2 Not a Source Filter
103 The used syntax elements are not parsed via source filter mechanism, but
104 through L<Devel::Declare>, which is a much less fragile deal to handle and
105 allows extensions to mix without problems. For example, all keywords added
106 by this module are separete handlers.
108 =head2 Syntax Documentation
110 The documentation about syntax is in the respective parts of the distribution
111 below the C<CatalystX::Declare::Keyword::> namespace. Here are the manual
112 pages you will be interested in to familiarize yourself with this module's
117 =item L<CatalystX::Declare::Keyword::Application>
119 =item L<CatalystX::Declare::Keyword::Controller>
121 =item L<CatalystX::Declare::Keyword::Action>
123 =item L<CatalystX::Declare::Keyword::Role>
127 Things like models, views, roles for request or response objects, can be built
128 declaratively with L<MooseX::Declare>, which is used to additionally provide
129 keywords for C<class>, C<role>, C<method> and the available method modifier
130 declarations. This allows for constructs such as:
132 use CatalystX::Declare;
139 controller MyApp::Web::Controller::Baz {
142 $ctx->response->body(Foo->new->bar)
148 =head2 For Usage Information
150 These links are intended for the common user of this module.
154 =item L<Catalyst::Runtime>
156 =item L<Catalyst::Devel>
158 =item L<Catalyst::Manual>
160 Although you probably already know Catalyst, since you otherwise probably
161 wouldn't be here, I include these links for completeness sake.
165 The powerful modern Perl object orientation implementation that is used
166 as basis for Catalyst. L<MooseX::Declare>, on which L<CatalystX::Declare>
167 is based, provides a declarative syntax for L<Moose>.
169 =item L<MooseX::Declare>
171 We inherit almost all functionality from L<MooseX::Declare> to allow the
172 declaration of traditional classes, roles, methods, modifiers, etc. Refer
173 to this documentation first for syntax elements that aren't part of
174 L<CatalystX::Declare>.
176 =item L<MooseX::Method::Signatures>
178 This isn't directly used, but L<MooseX::Declare> utilises this to provide
179 us with method and modifier declarations. For extended information on the
180 usage of methods, especially signatures, refer to this module after
181 looking for an answer in the L<MooseX::Declare> documentation.
185 =head2 For Developer Information
187 This section contains links relevant to the implementation of this module.
191 =item L<Devel::Declare>
193 You could call this is the basic machine room that runs the interaction with
194 perl. It provides a way to hook into perl's source code parsing and change
195 small parts on a per-statement basis.
197 =item L<MooseX::MethodAttributes>
199 We use this module to easily communicate the action attributes to
200 L<Catalyst|Catalyst::Runtime>. Currently, this is the easiest solution for
201 now but may be subject to change in the future.
210 =item Robert 'phaylon' Sedlacek, L<E<lt>rs@474.atE<gt>>
214 With contributions from, and many thanks to:
218 =item Florian Ragwitz
220 =item John Napiorkowski
227 This program is free software; you can redistribute it and/or modify it under
228 the same terms as perl itself.