mason: Use an autohandler for the HTML skeleton.
[bridge-toys] / mason / dhandler
index d7c1da5..7cf6ed6 100755 (executable)
 </%perl>
 </table>
 %#
-<%flags>
-       inherit => "%html"
-</%flags>
-%#
 <%args>
        $nbox => 4
        $nrow => 4
 </%args>
 %#
-<%method title>Single hand</%method>
+<%method title>\
+% if ($fail) {
+Not found\
+% } else {
+Single hand\
+% }
+</%method>
+%#
+<%def .not-found>
+<h1>Not found</h1>
+Failed to find &lsquo;<code><% $what |h %></code>&rsquo;.
+% return 404;
+<%args>
+       $what
+</%args>
+</%def>
 %#
 <%once>
        use Deal;
 </%once>
 %#
+<%shared>
+       my $fail = ($m->dhandler_arg ne "");
+</%shared>
+%#
 <%init>
-       unless ($m->dhandler_arg eq "") {
-         $m->clear_buffer;
-         $m->comp("%not-found", what => $m->dhandler_arg);
-       }
+       return $m->comp(".not-found", what => $m->dhandler_arg)
+         if $fail;
 </%init>