9338affee5ef3cd27864dd03d05c3ca159a1d8be
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Value / Image.pm
1 package Reaction::UI::Widget::Value::Image;
2
3 use Reaction::UI::WidgetClass;
4
5 use namespace::clean -except => [ qw(meta) ];
6
7
8 implements fragment image {
9     if($_{viewport}->value_string) {
10     arg uri => $_{viewport}->uri;
11     render 'has_image';
12   } else {
13     render 'no_image';
14   }
15 };
16
17 __PACKAGE__->meta->make_immutable;
18
19 =head1 NAME
20
21 Reaction::UI::Widget::Value::Image - An image tag or non-image alternative
22
23 =head1 DESCRIPTION
24
25 This widget allows you to render an image container that uses different
26 fragments for available and non-available images.
27
28 =head1 FRAGMENTS AND LAYOUTS
29
30 =head2 widget
31
32 Has only layout implementation. The widget fragment is inherited from
33 L<Reaction::UI::Widget>. The layout will simply render the
34 C<image> fragment. This fragment can be overwritten by your own layout to
35 render, for example, a frame around the image.
36
37 =head2 image
38
39 Is only implemented in the widget. If the viewport has a true value in
40 C<value_string>, the C<uri> argument will be set to the value of the C<uri>
41 attribute or method return value of the viewport, and the C<has_image>
42 fragment will be rendered. 
43
44 If C<value_string> is false, the C<no_image> fragment will be rendered.
45
46 =head2 has_image
47
48 This is only implemented in the layout file. It contains just an image
49 tag and will be rendered when the viewport has a true C<value_string>.
50
51 =head2 no_image
52
53 This has only an empty implementation in the layout file. It will output
54 nothing and is called when then viewport has a false C<value_string>.
55
56 =head1 LAYOUT TEMPLATE
57
58   share/skin/base/layout/value/image.tt
59
60 =head1 AUTHORS
61
62 See L<Reaction::Class> for authors.
63
64 =head1 LICENSE
65
66 See L<Reaction::Class> for the license.
67
68 =cut
69
70
71 1;