]> git.decadent.org.uk Git - maypole.git/blob - templates/factory/macros
2a2315523300949de9c7b48f103f28367a4cf9b9
[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         ELSIF col == "name";
19             maybe_link_view(item);
20         ELSE;
21             maybe_link_view(item.$col);
22         END;
23         "</td>";
24      END;
25     button(item, "edit");
26     button(item, "delete");
27 END %]
28
29 [% MACRO button(obj, action) BLOCK; %]
30 <TD>
31 <FORM METHOD="post" ACTION="[%base%]/[%obj.moniker%]/[%action%]/[%obj.id%]">
32     <INPUT TYPE="submit" NAME="[%action%]" VALUE="[%action%]">
33 </FORM>
34 </TD>
35 [% END %]
36