4 class CatalystX::Declare extends MooseX::Declare is dirty {
6 use aliased 'CatalystX::Declare::Keyword::Model', 'ModelKeyword';
7 use aliased 'CatalystX::Declare::Keyword::View', 'ViewKeyword';
8 use aliased 'CatalystX::Declare::Keyword::Controller', 'ControllerKeyword';
9 use aliased 'CatalystX::Declare::Keyword::Role', 'RoleKeyword';
10 use aliased 'CatalystX::Declare::Keyword::Application', 'ApplicationKeyword';
14 our $VERSION = '0.012';
16 around keywords (ClassName $self:) {
18 ControllerKeyword->new( identifier => 'controller' ),
19 RoleKeyword->new( identifier => 'controller_role' ),
20 ApplicationKeyword->new( identifier => 'application' ),
21 ViewKeyword->new( identifier => 'view' ),
22 ModelKeyword->new( identifier => 'model' ),
30 CatalystX::Declare - EXPERIMENTAL Declarative Syntax for Catalyst Applications
36 use CatalystX::Declare;
38 application MyApp::Web with Static::Simple {
40 $CLASS->config(name => 'My Declarative Web Application');
44 L<CatalystX::Declare::Keyword::Application>,
45 L<MooseX::Declare/class>
49 use CatalystX::Declare;
51 controller MyApp::Web::Controller::Foo
52 with MyApp::Web::ControllerRole::Bar {
54 use MooseX::Types::Moose qw( Str );
57 has welcome_message => (
64 method _build_welcome_message { 'Welcome' }
67 action base under '/' as '';
71 final action welcome {
72 $ctx->response->body( $self->welcome_message );
78 L<CatalystX::Declare::Keyword::Controller>,
79 L<CatalystX::Declare::Keyword::Action>,
80 L<CatalystX::Declare::Keyword::Component>,
81 L<MooseX::Declare/class>
85 use CatalystX::Declare;
87 controller_role MyApp::Web::ControllerRole::Bar {
89 use MyApp::Types qw( Username );
92 around _build_welcome_message { $self->$orig . '!' }
94 after welcome (Object $ctx) {
96 $ctx->response->body(join "\n",
103 final action special_welcome (Username $name) under base {
105 $ctx->response->body('Hugs to ' . $name);
110 L<CatalystX::Declare::Keyword::Role>,
111 L<CatalystX::Declare::Keyword::Action>,
112 L<MooseX::Declare/class>
116 use CatalystX::Declare;
118 view MyApp::Web::View::TT
119 extends Catalyst::View::TT {
122 TEMPLATE_EXTENSION => '.html',
127 L<CatalystX::Declare::Keyword::View>,
128 L<CatalystX::Declare::Keyword::Component>,
129 L<MooseX::Declare/class>
133 use CatalystX::Declare;
135 model MyApp::Web::Model::DBIC::Schema
136 extends Catalyst::Model::DBIC::Schema {
139 schema_class => 'MyApp::Schema',
144 L<CatalystX::Declare::Keyword::Model>,
145 L<CatalystX::Declare::Keyword::Component>,
146 L<MooseX::Declare/class>
150 B<This module is EXPERIMENTAL>
152 This module provides a declarative syntax for L<Catalyst|Catalyst::Runtime>
153 applications. Its main focus is currently on common and repetitious parts of
154 the application, such as the application class itself, controllers, and
157 =head2 Not a Source Filter
159 The used syntax elements are not parsed via source filter mechanism, but
160 through L<Devel::Declare>, which is a much less fragile deal to handle and
161 allows extensions to mix without problems. For example, all keywords added
162 by this module are separete handlers.
164 =head2 Syntax Documentation
166 The documentation about syntax is in the respective parts of the distribution
167 below the C<CatalystX::Declare::Keyword::> namespace. Here are the manual
168 pages you will be interested in to familiarize yourself with this module's
173 =item L<CatalystX::Declare::Keyword::Application>
175 =item L<CatalystX::Declare::Keyword::Action>
177 =item L<CatalystX::Declare::Keyword::Controller>
179 =item L<CatalystX::Declare::Keyword::Role>
181 =item L<CatalystX::Declare::Keyword::View>
183 =item L<CatalystX::Declare::Keyword::Model>
187 Things like models, views, roles for request or response objects, can be built
188 declaratively with L<MooseX::Declare>, which is used to additionally provide
189 keywords for C<class>, C<role>, C<method> and the available method modifier
190 declarations. This allows for constructs such as:
192 use CatalystX::Declare;
199 controller MyApp::Web::Controller::Baz {
201 final action qux under '/' {
202 $ctx->response->body(Foo->new->bar)
208 =head2 For Usage Information
210 These links are intended for the common user of this module.
214 =item L<Catalyst::Runtime>
216 =item L<Catalyst::Devel>
218 =item L<Catalyst::Manual>
220 Although you probably already know Catalyst, since you otherwise probably
221 wouldn't be here, I include these links for completeness sake.
225 The powerful modern Perl object orientation implementation that is used
226 as basis for Catalyst. L<MooseX::Declare>, on which L<CatalystX::Declare>
227 is based, provides a declarative syntax for L<Moose>.
229 =item L<MooseX::Declare>
231 We inherit almost all functionality from L<MooseX::Declare> to allow the
232 declaration of traditional classes, roles, methods, modifiers, etc. Refer
233 to this documentation first for syntax elements that aren't part of
234 L<CatalystX::Declare>.
236 =item L<MooseX::Method::Signatures>
238 This isn't directly used, but L<MooseX::Declare> utilises this to provide
239 us with method and modifier declarations. For extended information on the
240 usage of methods, especially signatures, refer to this module after
241 looking for an answer in the L<MooseX::Declare> documentation.
245 =head2 For Developer Information
247 This section contains links relevant to the implementation of this module.
251 =item L<Devel::Declare>
253 You could call this is the basic machine room that runs the interaction with
254 perl. It provides a way to hook into perl's source code parsing and change
255 small parts on a per-statement basis.
257 =item L<MooseX::MethodAttributes>
259 We use this module to easily communicate the action attributes to
260 L<Catalyst|Catalyst::Runtime>. Currently, this is the easiest solution for
261 now but may be subject to change in the future.
270 =item Robert 'phaylon' Sedlacek, L<E<lt>rs@474.atE<gt>>
274 With contributions from, and many thanks to:
278 =item Florian Ragwitz
280 =item John Napiorkowski
287 This program is free software; you can redistribute it and/or modify it under
288 the same terms as perl itself.