=== html/Ticket/Elements/ShowMessageStanza
==================================================================
--- html/Ticket/Elements/ShowMessageStanza	(revision 11720)
+++ html/Ticket/Elements/ShowMessageStanza	(local)
@@ -45,37 +45,39 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
-% if (ref($Message)) {
-<div class="message-stanza-depth-<% $Depth %>">
-<%perl>
-foreach my $stanza (@$Message) {
-    if ( ref $stanza eq "ARRAY" ) {
-        $m->comp( 'ShowMessageStanza',
-                  Depth   => $Depth + 1,
-                  Transaction => $Transaction,
-                  Message => $stanza );
+<%INIT>
+my $print_content = sub {
+    my $ref = shift;
+    return unless defined $$ref && length $$ref;
+    
+    RT::Interface::Web::EscapeUTF8( $ref );
+    $m->comp('/Elements/Callback', content => $ref, %ARGS );
+    $$ref =~ s{$}{<br />}mg if defined $$ref;
+    $m->out( $$ref );
+};
+my $print_message;
+$print_message = sub {
+    my ($msg, $txn, $depth) = @_;
+    if ( ref $msg ) {
+        $m->out( qq{<div class="message-stanza-depth-$depth">} );
+        my $para = '';
+        foreach my $stanza ( @$msg ) {
+            if ( ref $stanza eq "ARRAY" ) {
+                $print_content->( \$para ); $para = '';
+                $print_message->( $stanza, $txn, $depth + 1 );
+            }
+            elsif ( ref $stanza eq "HASH" ) {
+                $para .= $stanza->{raw} if defined $stanza->{raw};
+                $para .= "\n";
+            }
+        }
+        $print_content->( \$para ) if length $para;
+        $m->out( '</div>' );
+    } else {
+        $print_content->( \$msg );
     }
-    elsif ( ref $stanza eq "HASH" ) {
-        my $content = $stanza->{raw};
-        RT::Interface::Web::EscapeUTF8(\$content);
-        $m->comp('/Elements/Callback', content => \$content, %ARGS);
-        $content =~ s{$}{<br />}mg
-            if defined $content;
-
-</%perl>
-<%$content |n%>
-%   }
-% } # end foreach
-</div>
-% } else {
-%       my $content = $Message;
-%       RT::Interface::Web::EscapeUTF8(\$content);
-%       $m->comp('/Elements/Callback', content => \$content, %ARGS);
-%       $content =~ s{$}{<br />}mg;
-<%$content |n%>
-% }
-<%INIT>
-use URI::URL;
+};
+return $print_message->( $Message, $Transaction, $Depth );
 </%INIT>
 <%ARGS>
 $Message => undef
