search spec components factored out of T365
[catagits/Reaction.git] / lib / Reaction / UI / Widget / URI.pm
CommitLineData
36fb39fa 1package Reaction::UI::Widget::URI;
2
3use Reaction::UI::WidgetClass;
4use namespace::clean -except => [ qw(meta) ];
5
6before fragment widget {
7 arg uri => $_{viewport}->uri;
8};
9
10implements fragment display_fragment {
11 my $vp = $_{viewport};
12 return unless $vp->has_display;
13 my $display = $vp->display;
14 if( blessed($display) && $display->isa('Reaction::UI::ViewPort')){
15 arg '_' => $display;
16 render 'viewport';
17 } else {
18 arg string_value => $display;
19 render 'display_string';
20 }
21};
22
23__PACKAGE__->meta->make_immutable;
24
25
261;
27
28__END__;
f9b32c83 29
30=head1 NAME
31
32Reaction::UI::Widget::URI - A hyperlink reference by URI value
33
34=head1 DESCRIPTION
35
36This widget allows a layout template to render a hyperlink with either a
37simple string or another viewport as the contents of the link.
38
39=head1 FRAGMENTS
40
41=head2 widget
42
43Before the C<widget> fragment is rendered, the C<uri> argument will be set
44to the return value of the C<uri> method on the viewport. The layout
45will render a hyperlink with the C<uri> as value of the C<href> attribute and
46the C<display_fragment> fragment as content of the element.
47
48=head2 display_fragment
49
50This will render nothing if the viewport doesn't return true when C<has_display>
51is called on it. If it has a C<display> defined and it is a viewport, the C<_>
52argument will be set to it and the C<viewport> fragment (inherited from
53L<Reaction::UI::Widget> will be rendered. If the C<display> is not a viewport,
54the C<string_value> argument will be set and the C<display_string> layout
55will be rendered.
56
57C<display_fragment> is only implemented in the widget class.
58
59=head2 display_string
60
61Only implemented in the layout set. This will simply output the value of the
62C<string_value> argument as content of the hyperlink element.
63
64=head1 LAYOUT SET
65
66 share/skin/base/layout/uri.tt
67
68This layout set will look for a widget called C<URI> in the
69C<widget_search_path>.
70
71=head1 AUTHORS
72
73See L<Reaction::Class> for authors.
74
75=head1 LICENSE
76
77See L<Reaction::Class> for the license.
78
79=cut