]> git.decadent.org.uk Git - maypole.git/blob - templates/factory/macros
Make the view page a bit prettier, and link has-a and url links nicely.
[maypole.git] / templates / factory / macros
1 [% MACRO maybe_link_view(object) BLOCK;
2     IF object.moniker; # It's an object, i.e. a has-a
3         "<A HREF='" _ base _ object.moniker _ "/view/" _ object.id _"'>";
4         object;
5         "</A>";
6     ELSE;
7         object;
8     END;
9 END;
10 %]
11
12 [% MACRO display_line(item) BLOCK;
13      FOR col = classmetadata.columns;
14         NEXT IF col == "id";
15         "<td>";
16         IF col == "url";  # Possibly too much magic.
17             "<A HREF="; item.url; "> "; item.url; "</A>";
18         ELSE;
19             maybe_link_view(item.$col);
20         END;
21         "</td>";
22      END;
23     button(item, "edit");
24     button(item, "delete");
25 END %]
26
27 [% MACRO button(obj, action) BLOCK; %]
28 <TD>
29 <FORM METHOD="post" ACTION="[%base%]/[%obj.moniker%]/[%action%]/[%obj.id%]">
30     <INPUT TYPE="submit" NAME="[%action%]" VALUE="[%action%]">
31 </FORM>
32 </TD>
33 [% END %]
34