Index: branches/htmlform/cgi-bin/main.cgi
===================================================================
--- branches/htmlform/cgi-bin/main.cgi	(revision 464)
+++ branches/htmlform/cgi-bin/main.cgi	(revision 465)
@@ -308,10 +308,9 @@
 sub showMaster {
 
-  print qq(<center><div class="heading">Summarizing routed blocks for ).
-	qq($webvar{block}:</div></center><br>\n);
+  $page->param(master => $webvar{block});
 
   my %allocated;
   my %free;
-  my %routed;
+  my %cities;
   my %bigfree;
 
@@ -331,11 +330,9 @@
     $bigfree{"$cidr"} = 128;
     # Retain the routing destination
-    $routed{"$cidr"} = $data[1];
+    $cities{"$cidr"} = $data[1];
   }
 
   # Check if there were actually any blocks routed from this master
   if ($i > 0) {
-    startTable('Routed block','Routed to','Allocated blocks',
-	'Free blocks','Largest free block');
 
     # Count the allocations
@@ -365,36 +362,23 @@
     }
 
-    # Print the data.
-    my $count=0;
+    my @routed;
+    my $rowclass = 0;
     foreach my $master (@localmasters) {
-      my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=showrouted&block=$master\">$master</a>",
-	$routed{"$master"}, $allocated{"$master"},
-	$free{"$master"},
-	( ($bigfree{"$master"} eq 128) ? ("&lt;NONE&gt;") : ("/".$bigfree{"$master"}) )
-      );
-      printRow(\@row, 'color1' ) if($count%2==0);
-      printRow(\@row, 'color2' ) if($count%2!=0);
-      $count++;
-    }
-  } else {
-    # If a master block has no routed blocks, then by definition it has no
-    # allocations, and can be deleted.
-    print qq(<hr width="60%"><center><div class="heading">No allocations in ).
-        qq($master.</div>\n).
-	($IPDBacl{$authuser} =~ /d/ ?
-	        qq(<form action="/ip/cgi-bin/main.cgi" method=POST>\n).
-	        qq(<input type=hidden name=action value="delete">\n).
-	        qq(<input type=hidden name=block value="$master">\n).
-	        qq(<input type=hidden name=alloctype value="mm">\n).
-	        qq(<input type=submit value=" Remove this master ">\n).
-	        qq(</form></center>\n) :
-		'');
+      my %row = (
+	rowclass => $rowclass % 2,
+	block => "$master",
+	city => $cities{"$master"},
+	nsubs => $allocated{"$master"},
+	nfree => $free{"$master"},
+	lfree => ( ($bigfree{"$master"} eq 128) ? ("&lt;NONE&gt;") : ("/".$bigfree{"$master"}) )
+	);
+      push @routed, \%row;
+      $rowclass++;
+    }
+    $page->param(routedlist => \@routed);
 
   } # end check for existence of routed blocks in master
 
-  print qq(</table>\n<hr width="60%">\n).
-	qq(<center><div class="heading">Unrouted blocks in $master:</div></center><br>\n);
-
-  startTable('Netblock','Range');
+  $page->param(delmaster => ($IPDBacl{$authuser} =~ /d/));
 
   # Snag the free blocks.
@@ -403,13 +387,18 @@
 	"routed='n' order by cidr");
   $sth->execute();
+  my @unrouted;
+  my $rowclass = 0;
   while (my @data = $sth->fetchrow_array()) {
     my $cidr = new NetAddr::IP $data[0];
-    my @row = ("$cidr", $cidr->range);
-    printRow(\@row, 'color1' ) if($count%2==0);
-    printRow(\@row, 'color2' ) if($count%2!=0);
-    $count++;
-  }
-
-  print "</table>\n";
+    my %row = (
+	rowclass => $rowclass % 2,
+	fblock => "$cidr",
+	frange => $cidr->range
+	);
+    push @unrouted, \%row;
+    $rowclass++;
+  }
+  $page->param(unrouted => \@unrouted);
+
 } # showMaster
 
Index: branches/htmlform/ipdb.css
===================================================================
--- branches/htmlform/ipdb.css	(revision 464)
+++ branches/htmlform/ipdb.css	(revision 465)
@@ -88,4 +88,5 @@
 	margin-left: auto;
 	margin-right: auto;
+	text-align: center;
 }
 
@@ -106,4 +107,8 @@
 }
 
+hr.w60 {
+	width: 60%;
+}
+
 /* legacy defs */
 tr.color0 {
@@ -165,4 +170,10 @@
 }
 
+.tbltitle {
+	text-align: center;
+	font-size: 110%;
+	font-weight: bold;
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+}
 .tblsubtitle {
         font-size: 105%;
Index: branches/htmlform/templates/showmaster.tmpl
===================================================================
--- branches/htmlform/templates/showmaster.tmpl	(revision 465)
+++ branches/htmlform/templates/showmaster.tmpl	(revision 465)
@@ -0,0 +1,66 @@
+<div class="tbltitle">Summarizing routed blocks for <TMPL_VAR NAME=master>:</div>
+<br>
+
+<TMPL_IF routedlist>
+<table class="centre" width="98%" cellspacing="0">
+<tr>
+<td class="heading">Routed block</td>
+<td class="heading">Routed to</td>
+<td class="heading">Allocated blocks</td>
+<td class="heading">Free blocks</td>
+<td class="heading">Largest free block</td>
+</tr>
+
+<TMPL_LOOP NAME=routedlist>
+<tr class="row<TMPL_VAR NAME=rowclass>">
+<td><a href="/ip/cgi-bin/main.cgi?action=showrouted&amp;block=<TMPL_VAR NAME=block>"><TMPL_VAR NAME=block></a></td>
+<td><TMPL_VAR NAME=city></td>
+<td><TMPL_VAR NAME=nsubs></td>
+<td><TMPL_VAR NAME=nfree></td>
+<td><TMPL_VAR NAME=lfree></td>
+</tr>
+</TMPL_LOOP>
+</table>
+<TMPL_ELSE>
+<hr class="w60">
+<div class="tbltitle">No allocations in <TMPL_VAR NAME=master>.
+<TMPL_IF delmaster>
+<br>
+<form action="/ip/cgi-bin/main.cgi" method=POST>
+<fieldset><legend></legend>
+<input type=hidden name=action value="delete">
+<input type=hidden name=block value="$master">
+<input type=hidden name=alloctype value="mm">
+<input type=submit value=" Remove this master ">
+</fieldset>
+</form>
+</TMPL_IF>
+</div>
+</TMPL_IF>
+
+<br>
+<hr class="w60">
+<br>
+
+<div class="tbltitle">Unrouted blocks in <TMPL_VAR NAME=master>:</div>
+<br>
+
+<TMPL_IF NAME=unrouted>
+<table class="centre" width="98%" cellspacing="0">
+<tr>
+<td class="heading">Netblock</td>
+<td class="heading">Range</td>
+</tr>
+
+<TMPL_LOOP name=unrouted>
+<tr class="row<TMPL_VAR NAME=rowclass>">
+<td><TMPL_VAR NAME=fblock></td>
+<td><TMPL_VAR NAME=frange></td>
+</tr>
+</TMPL_LOOP>
+
+</table>
+<TMPL_ELSE>
+<hr class="w60">
+<div class="tbltitle">No unrouted blocks in <TMPL_VAR NAME=master>.</div>
+</TMPL_IF>
