5 These are some default macros which are used by various templates in the
10 This creates an <A HREF="... to a command in the Apache::MVC system by
11 catenating the base URL, table, command, and any arguments.
15 MACRO link(table, command, additional, label) BLOCK;
16 '<A HREF="' _ base _ table _ "/" _ command _ "/" _ additional _ '">';
24 =head2 maybe_link_view
26 C<maybe_link_view> takes something returned from the database - either
27 some ordinary data, or an object in a related class expanded by a
28 has-a relationship. If it is an object, it constructs a link to the view
29 command for that object. Otherwise, it just displays the data.
34 MACRO maybe_link_view(object) BLOCK;
35 IF object.moniker; # It's an object, i.e. a has-a
36 link(object.moniker, "view", object.id, object);
47 C<display_line> is used in the list template to display a row from the
48 database, by iterating over the columns and displaying the data for each
49 column. It misses out the C<id> column by default, and magically
50 URLifies columns called C<url>. This may be considered too much magic
54 [% MACRO display_line(item) BLOCK;
55 FOR col = classmetadata.columns;
59 "<A HREF="; item.url; "> "; item.url; "</A>";
61 maybe_link_view(item);
63 maybe_link_view(item.$col);
68 button(item, "delete");
74 This is a generic button, which performs an action on an object.
79 [% MACRO button(obj, action) BLOCK; %]
81 <FORM METHOD="post" ACTION="[%base%]/[%obj.moniker%]/[%action%]/[%obj.id%]">
82 <INPUT TYPE="submit" NAME="[%action%]" VALUE="[%action%]">
90 This takes an object, and looks up the C<related_accessors>; this should
91 give a list of accessors that can be called to get a list of related
92 objects. It then displays a title for that accessor, (i.e. "Beers" for a
93 brewery) calls the accesor, and displays a list of the results.
99 MACRO view_related(object) BLOCK;
100 FOR accessor = classmetadata.related_accessors.list;
101 "<H3>"; accessor | ucfirst; "</H3>\n";
103 FOR thing = object.$accessor;
104 "<LI>"; maybe_link_view(thing); "</LI>\n";
110 MACRO test_xxxx(myblock) BLOCK;
111 FOR col = classmetadata.columns;