3 Reaction::Manual::Templates
7 This is a detailed description of reaction's template system.
15 Reaction's templates are organized into sets called skins. A skin is defined by
16 a directory containing several template files and static assets. Skins live in
17 directories under the C<share/skin> path in your application distribution. Each
18 directory and the template files within compose their own skin. Templates live
19 in the C<layout> directory and assets live in the C<web> directory.
23 Reaction provides prebuilt skins called C<base> and C<default>. These provide
24 the basic html components for a typical web application, such as forms, fields
25 and table list views. Skins are extensible, which means you can include all the
26 templates from another skin within your custom skin through a configuration
27 directive instead of copying template files, making your template setup easy to
30 =head3 Configuration Directives
32 The C<share/skin/defaults.conf> file holds general application-wide skin
33 configuration. Each skin can be configured individually by placing a C<skin.conf>
34 file in it's root directory.
38 =item * extends $skin_name
40 Defines C<$skin_name> as the base skin.
46 Template files are sets of pod-like directives which define a set of layouts.
47 They are used for the sole purpose of describing how the data is to be layed out
48 at render time. Each template file contains a set of layout definitions which are
49 used by reaction widgets to generate the final content. Variables are defined and
50 populated in the widgets then passed to the layout fragments in a given template
53 =head3 Template Directives
57 =item * =for layout $fragment_name
59 Defines a layout fragment called C<$fragment_name>, everything under the
60 directive up to the next fragment directive is part of the definition. By default,
61 variables with the same name as an existing layout definition are rendered as the
62 equivalent layout. Widgets might interfere and select an alternate layout or
63 template to be rendered instead. A templates' rendering process always starts by
64 a layout called C<widget>.
66 =item * =extends $template_name
68 Makes the current template inherit the layout definitions in C<$template_name>.
69 Layouts defined in the template override the ones in the base template. The
70 special C<NEXT> template name specifies that inheritance should use the equivalent
71 template from the base skin as configured in C<skin.conf>.
73 =item * =widget $widget_name
75 Selects C<$widget_name> as the driver for the current template.
79 =head2 LAYOUT FRAGMENTS
83 A layout definition creates a variable scope attached to that layout. Variables
84 only exist within their specific layout fragments, that is, they are scoped to
85 specific layouts. Overriding a layout places it in the same scope as the base layout.
87 =head3 Using layouts defined in base templates
89 The special [% call_next %] variable will be replaced by the layout in the base
90 template within the same scope.