[Jifty-commit] r4160 - jifty/trunk/lib/Jifty/Web/Form

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Sep 27 14:50:31 EDT 2007


Author: clkao
Date: Thu Sep 27 14:50:29 2007
New Revision: 4160

Modified:
   jifty/trunk/lib/Jifty/Web/Form/Link.pm

Log:
New as_string method for Jifty::Web::Form::Link.


Modified: jifty/trunk/lib/Jifty/Web/Form/Link.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Link.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Link.pm	Thu Sep 27 14:50:29 2007
@@ -86,15 +86,14 @@
 
 =cut
 
-=head2 render
+=head2 as_string
 
-Render the string of the link, including any necessary javascript.
+Returns the string of the link, including any necessary javascript.
 
 =cut
 
-sub render {
+sub as_string {
     my $self = shift;
-
     my $label = $self->label;
     $label = Jifty->web->escape( $label )
         if ( $self->escape_label );
@@ -103,17 +102,38 @@
     $tooltip = Jifty->web->escape( $tooltip )
         if ( defined $tooltip and $self->escape_label );
 
-    Jifty->web->out(qq(<a));
-    Jifty->web->out(qq( id="@{[$self->id]}"))         if $self->id;
-    Jifty->web->out(qq( class="@{[$self->class]}"))   if $self->class;
-    Jifty->web->out(qq( title="@{[$tooltip]}"))       if defined $tooltip;
-    Jifty->web->out(qq( target="@{[$self->target]}")) if $self->target;
-    Jifty->web->out(qq( accesskey="@{[$self->key_binding]}")) if $self->key_binding;
-    Jifty->web->out(qq( href="@{[Jifty->web->escape($self->url)]}"));
-    Jifty->web->out( $self->javascript() );
-    Jifty->web->out(qq(>$label</a>));
-    $self->render_key_binding();
+    my $output = '';
+
+    $output .= (qq(<a));
+    $output .= (qq( id="@{[$self->id]}"))         if $self->id;
+    $output .= (qq( class="@{[$self->class]}"))   if $self->class;
+    $output .= (qq( title="@{[$tooltip]}"))       if defined $tooltip;
+    $output .= (qq( target="@{[$self->target]}")) if $self->target;
+    $output .= (qq( accesskey="@{[$self->key_binding]}")) if $self->key_binding;
+    $output .= (qq( href="@{[Jifty->web->escape($self->url)]}"));
+    $output .= ( $self->javascript() );
+    $output .= (qq(>$label</a>));
+
+    $output .= (
+        '<script type="text/javascript"><!--' .
+        "\n" .
+        Jifty->web->escape($self->key_binding_javascript).
+        "\n" .
+        "--></script>") if $self->key_binding;
+
+    return $output;
+}
+
+=head2 render
+
+Render the string of the link, including any necessary javascript.
+
+=cut
+
+sub render {
+    my $self = shift;
 
+    Jifty->web->out($self->as_string);
     return ('');
 }
 


More information about the Jifty-commit mailing list