X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2Ftemplates%2Ffactory%2Fmacros;h=8267d926de4a157445a6934dccab74163625fee3;hb=dd369c8a18080c4f27237f23b5842d53da05f570;hp=a102c736a523dd78677661140fec7d0400892ca3;hpb=4a5cef989c825acf0eb66ba6e567fdd8d47c4da4;p=maypole.git diff --git a/lib/Maypole/templates/factory/macros b/lib/Maypole/templates/factory/macros index a102c73..8267d92 100644 --- a/lib/Maypole/templates/factory/macros +++ b/lib/Maypole/templates/factory/macros @@ -14,9 +14,9 @@ catenating the base URL, table, command, and any arguments. [% MACRO link(table, command, additional, label) BLOCK; SET lnk = base _ "/" _ table _ "/" _ command _ "/" _ additional; - lnk = lnk | uri | html; + lnk = lnk | uri ; ''; - label; + label | html; ""; END; %] @@ -37,7 +37,7 @@ MACRO maybe_link_view(object) BLOCK; IF object.isa('Maypole::Model::Base'); link(object.table, "view", object.id.join('/'), object); ELSE; - object; + object | html ; END; END; %] @@ -56,15 +56,20 @@ for some. [% MACRO display_line(item) BLOCK; FOR col = classmetadata.list_columns; NEXT IF col == "id" OR col == classmetadata.table _ "_id"; + col_obj = item.find_column(col); ""; IF col == "url" AND item.url; - ' '; item.url; ''; + ' '; item.url; ''; ELSIF col == classmetadata.stringify_column; maybe_link_view(item); - ELSE; - accessor = item.accessor_name(col); + ELSIF col_obj; # its a real column + accessor = item.accessor_name_for(col_obj) || + item.accessor_name(col_obj); # deprecated in cdbi maybe_link_view(item.$accessor); + ELSE; + item.$col; END; + ""; END; ''; @@ -129,12 +134,12 @@ This takes an object and and displays its properties in a table. #%] [% MACRO view_item(item) BLOCK; %] [% SET string = classmetadata.stringify_column %] -
[% item.$string %]
+
[% item.$string | html %]
[% INCLUDE navbar %] - - + + [% FOR col = classmetadata.columns.list; NEXT IF col == "id" OR col == string OR col == classmetadata.table _ "_id";; @@ -149,11 +154,18 @@ from the C method: #%] - +
[% classmetadata.colnames.$string %][% item.$string %][% classmetadata.colnames.$string %][% item.$string | html %]
[% classmetadata.colnames.$col; %][% classmetadata.colnames.$col || + col | ucfirst | replace('_',' '); %] [% IF col == "url" && item.url; # Possibly too much magic. - ' '; item.url; ''; + ' '; item.url; ''; + ELSIF item.$col.size > 1; # has_many column + FOR thing IN item.$col; + maybe_link_view(thing);", "; + END; + ELSE; + maybe_link_view(item.$col); END; %] [%#