- Adapt widget and layout to changes
- Add example of explicitly stating action to ComponentUI
- Don't override custom location in push_viewport
+ - Wire layout_args, which was forgotten + example of how to use it
0.002000 - 29 Apr 2008
- Update CheckUniques role to use around instead of overrides
- Stop using ACCEPT_CONTEXT, use InstancePerContext instead
sub root :Chained('base') :PathPart('') :Args(0) {
my ($self, $c) = @_;
- $self->push_viewport(ViewPort, layout => 'index');
+ $self->push_viewport(
+ ViewPort, (
+ layout => 'index',
+ layout_args => {
+ user_agent => $c->request->user_agent,
+ message_to_layout => 'I hate programming.',
+ },
+ ),
+ );
+ $c->log->debug('remote', $c->request->remote_user );
}
sub bye :Chained('base') :PathPart('bye') :Args(0) {
--- /dev/null
+package ComponentUI::UI::Widget::Index;
+
+use Reaction::UI::WidgetClass;
+use namespace::clean -except => [ qw(meta) ];
+
+after fragment widget {
+ $_{viewport}->ctx->log->debug('widget');
+ arg message_to_layout => $_{layout_message};
+};
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+
+__END__
my ($self, $vp) = @_;
my $layout_set = $self->layout_set_for($vp);
my $widget = $self->widget_for($vp, $layout_set);
- return ($widget, { viewport => $vp });
+ my %layout_args = (%{ $vp->layout_args }, viewport => $vp);
+ return ($widget, \%layout_args);
};
sub widget_for {
my ($self, $vp, $layout_set) = @_;
C<push_viewport>, or it will be determined using the last part of the
ViewPorts classname.
+=item layout_args
+
+This read-only hashref attribute will pass all it's keys as variables to the
+layout at render time. They should be accessible from both the layout templates
+and the widget, if applicable, through the C<%_> hash.
+
+ $controller->push_viewport(VPName, layout => 'foo', layout_args => { bar => 'bar'});
+ $_{bar} #in widget
+ [% bar %] in template
+
=item column_order
This is generally used by more specialised ViewPorts such as the
+=widget Index
+
=for layout widget
-<p>I hate programming.</p>
+<p> [% user_agent %] sucks. [% message_to_layout %]</p>
-=cut
\ No newline at end of file
+=cut
+widget_search_path ComponentUI::UI::Widget
widget_search_path Reaction::UI::Widget