cbd69b7caeb67a8d1ccda955b3c1b53fd3d1145e
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Value / Collection.pm
1 package Reaction::UI::Widget::Value::Collection;
2
3 use Reaction::UI::WidgetClass;
4
5 use namespace::clean -except => [ qw(meta) ];
6
7
8 before fragment widget {
9   arg 'label' => localized $_{viewport}->label;
10 };
11
12 implements fragment list {
13   render 'item' => over $_{viewport}->value_names;
14 };
15
16 implements fragment item {
17   arg 'name' => localized $_;
18 };
19
20 __PACKAGE__->meta->make_immutable;
21
22
23 1;
24
25 __END__;
26
27
28 =head1 NAME
29
30 Reaction::UI::Widget::Value::Collection
31
32 =head1 DESCRIPTION
33
34 This widget provides an additional C<label> argument for the C<widget>
35 fragment containing the localised value of the viewports C<label> attribute.
36
37 It also implements the fragments C<list> and C<item>. 
38
39 =head1 FRAGMENTS AND LAYOUTS
40
41 =head2 widget
42
43 This will set the C<label> argument to the return value of the C<label> method
44 on the viewport. The base layout will then render the C<list> fragment.
45
46 =head2 list
47
48 This will render the C<item> fragment once for every entry in the viewports
49 C<value_names>. The base layout will surround the rendered output with a unordered
50 list.
51
52 =head2 item
53
54 This will set the argument C<name> to the localised value of the current iteration
55 (stored in C<$_>). The base layout will render a list item with the value as
56 html escaped content of the item.
57
58 =head1 LAYOUT SETS
59
60   share/skin/base/layout/value/collection.tt
61   share/skin/base/layout/value/list.tt
62
63 =head1 AUTHORS
64
65 See L<Reaction::Class> for authors.
66
67 =head1 LICENSE
68
69 See L<Reaction::Class> for the license.
70
71 =cut