[Jifty-commit] r1131 - in jifty/trunk: lib/Jifty/Web

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed May 31 13:27:09 EDT 2006


Author: alexmv
Date: Wed May 31 13:27:02 2006
New Revision: 1131

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Web/Menu.pm

Log:
 r13375 at zoq-fot-pik:  chmrr | 2006-05-31 13:26:41 -0400
  * Workaround for double-stringification of links in as_link.  Really
 need to fix render_* methods to use context to do the Right Thing.


Modified: jifty/trunk/lib/Jifty/Web/Menu.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Menu.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Menu.pm	Wed May 31 13:27:02 2006
@@ -217,7 +217,7 @@
     Jifty->web->out( qq{<li class="toplevel }
             . ( $self->active ? 'open active' : 'closed' ) . qq{">}
             . qq{<span class="title">} );
-    Jifty->web->out( $self->as_link() );
+    Jifty->web->out( $self->as_link );
     Jifty->web->out(qq{</span>});
     if (@kids) {
         Jifty->web->out(
@@ -245,7 +245,8 @@
 
 =head2 as_link
 
-Return this menu item as a C<Jifty::Web::Link>, either the one we were initialized with or a new one made from the C</label> and c</url>
+Return this menu item as a C<Jifty::Web::Link>, either the one we were
+initialized with or a new one made from the C</label> and c</url>
 
 If there's no C</url> and no C</link>, renders just the label.
 
@@ -253,11 +254,13 @@
 
 sub as_link {
     my $self = shift;
-    if ( $self->link ) {
-        return $self->link;
+    # Stringifying $self->link may return '' and output something, so
+    # we need to be careful to not stringify it more than once, and to
+    # check it for defined-ness, not truth.
+    if ( defined (my $str = $self->link) ) {
+        return $str;
     } elsif ( $self->url ) {
         return Jifty->web->link( label => _( $self->label ), url => $self->url );
-
     } else {
         return _( $self->label );
     }


More information about the Jifty-commit mailing list