search spec components factored out of T365
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Data.pm
1 package Reaction::UI::Widget::Data;
2
3 use Reaction::UI::WidgetClass;
4 use namespace::clean -except => [qw(meta)];
5
6 extends 'Reaction::UI::Widget::Container';
7
8 before fragment widget {
9   my $data = $_{viewport}->args;
10   arg $_ => $data->{$_} for keys %$data;
11 };
12
13 1;
14
15 __END__
16
17 =head1 NAME
18
19 Reaction::UI::Widget::Data - Abstract class to render a data hash reference
20
21 =head1 DESCRIPTION
22
23 This takes the C<args> method return value of the viewport and populates the
24 arguments with names and values from that value.
25
26 =head1 FRAGMENTS
27
28 =head2 widget
29
30 Sets an argument for every key and value in the viewport's C<args> method return
31 value (which is expected to be a hash reference).
32
33 =head1 EXAMPLE LAYOUT
34
35 Assuming this hash reference:
36
37   { first_name => "Foo", last_name => "Bar" }
38
39 we can access it in a layout set like this:
40
41   =widget Data
42   
43   =for layout widget
44   
45   Hello [% last_name | html %], [% first_name | html %]!
46   
47   =cut
48
49 =head1 AUTHORS
50
51 See L<Reaction::Class> for authors.
52
53 =head1 LICENSE
54
55 See L<Reaction::Class> for the license.
56
57 =cut