[Jifty-commit] r893 - in jifty/trunk: lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Apr 22 17:29:25 EDT 2006


Author: jesse
Date: Sat Apr 22 17:29:24 2006
New Revision: 893

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

Log:
 r11777 at hualien:  jesse | 2006-04-22 17:28:37 -0400
 * Added an API for rendering just one action's results
 


Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm	(original)
+++ jifty/trunk/lib/Jifty/Web.pm	Sat Apr 22 17:29:24 2006
@@ -720,32 +720,39 @@
     $self->link( call => $continuation, %args );
 }
 
-=head3 render_messages
+=head3 render_messages [MONIKER]
 
 Outputs any messages that have been added, in a <div id="messages">
 tag.  Messages are added by calling L<Jifty::Result/message>.
 
+If a moniker is specified, only messages for that moniker 
+are rendered.
+
+
 =cut
 
 # XXX TODO factor out error and message rendering as separate
 
 sub render_messages {
     my $self = shift;
-
+    my $only_moniker = '';
+    $only_moniker = shift if (@_);
     my %results = $self->response->results;
 
     return '' unless %results;
 
+    my @monikers = ($only_moniker) || sort keys %results;
+
     for my $type (qw(error message)) {
-        next unless grep { $results{$_}->$type() } keys %results;
+        next unless grep { $results{$_}->$type() } @monikers;
 
         my $plural = $type . "s";
         $self->out(qq{<div id="$plural">});
-        foreach my $moniker ( keys %results ) {
+        foreach my $moniker ( @monikers ) {
             if ( $results{$moniker}->$type() ) {
-                $self->out(qq{<div class="$type $moniker">});
-                $self->out( $results{$moniker}->$type() );
-                $self->out(qq{</div>});
+                $self->out( qq{<div class="$type $moniker">}
+                    . $results{$moniker}->$type()
+                    . qq{</div>} );
             }
         }
         $self->out(qq{</div>});


More information about the Jifty-commit mailing list