[Jifty-commit] r7631 - jifty/trunk/lib/Jifty/Web
Jifty commits
jifty-commit at lists.jifty.org
Wed Nov 18 14:00:35 EST 2009
Author: jesse
Date: Wed Nov 18 14:00:24 2009
New Revision: 7631
Modified:
jifty/trunk/lib/Jifty/Web/Menu.pm
Log:
Make it possible to inject a menu object into Jifty::Web::Menus
Modified: jifty/trunk/lib/Jifty/Web/Menu.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Menu.pm (original)
+++ jifty/trunk/lib/Jifty/Web/Menu.pm Wed Nov 18 14:00:24 2009
@@ -152,6 +152,10 @@
pre-existing child's sort order (if a C<KEY> is being over-written) or
the end of the list, if it is a new C<KEY>.
+If the paramhash contains a key called C<menu>, that will be used instead
+of creating a new Jifty::Web::Menu.
+
+
=cut
sub child {
@@ -159,18 +163,23 @@
my $key = shift;
my $proto = ref $self || $self;
- if (@_) {
+ if (my %args = @_) {
# Clear children ordering cache
delete $self->{children_list};
+ my $child;
+ if($child = $args{menu}) {
+ $child->parent($self);
+ }
+ else {
# Set us up the child
- my $child = $proto->new({parent => $self,
- sort_order => ($self->{children}{$key}{sort_order}
- || scalar values %{$self->{children}}),
+ $child = $proto->new({parent => $self,
+ sort_order => ($self->{children}{$key}{sort_order} || scalar values %{$self->{children}}),
label => $key,
escape_label => 1,
- @_
+ %args
});
+ }
$self->{children}{$key} = $child;
# URL is relative to parents, and cached, so set it up now
More information about the Jifty-commit
mailing list