5 The C<view> template takes some objects (usually just one) from
6 C<objects> and displays the object's properties in a table.
14 [% FOR item = objects %]
15 <h2> [% item.name %]</h2>
20 <TR><TD class="field">Name</TD><TD> [% item.name %] </TD></TR>
22 FOR col = classmetadata.columns.list;
23 NEXT IF col == "id" OR col == "name";
24 NEXT UNLESS item.$col;
31 It gets the displayable form of a column's name from the hash returned
32 from the C<column_names> method:
37 <TD class="field"> [% classmetadata.colnames.$col; %] </TD>
42 IF col == "url"; # Possibly too much magic.
43 "<A HREF="; item.url; "> "; item.url; "</A>";
48 #One interesting macro used in this template is C<maybe_link_view>:
50 maybe_link_view(item.$col);
55 This tests whether or not the returned value is an object, and if so,
56 creates a link to a page viewing that object; if not, it just displays
57 the text as normal. The object is linked using its stringified name;
58 by default this calls the C<name> method, or returns the object's ID
59 if there is no C<name> method or other stringification method defined.
75 The C<view> template also displays a list of other objects related to the first
76 one via C<has_many> style relationships; this is done by calling the
77 C<related_accessors> method - see L<Model/related_accessors> - to return
78 a list of has-many accessors. Next it calls each of those accessors, and
79 displays the results in a table.
88 button(item, "delete");