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