X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2Ftemplates%2Ffactory%2Fmacros;h=ddaeae1bf8e23bff911e551561a3df504fafb1d8;hb=a4b491683c59a0a505501187742b145eb538eb93;hp=cbf58bb21902fd0b1f80a907190363aa184ecf1b;hpb=a02686080acb66fce170e9657e110761b09e62a2;p=maypole.git diff --git a/lib/Maypole/templates/factory/macros b/lib/Maypole/templates/factory/macros index cbf58bb..ddaeae1 100644 --- a/lib/Maypole/templates/factory/macros +++ b/lib/Maypole/templates/factory/macros @@ -10,12 +10,20 @@ system. This creates an to a command in the Apache::MVC system by catenating the base URL, table, command, and any arguments. +arguments are table, command, additional, label, target. + +target specifies a target for the link if provided. + #%] [% -MACRO link(table, command, additional, label) BLOCK; +MACRO link(table, command, additional, label, target) BLOCK; SET lnk = base _ "/" _ table _ "/" _ command _ "/" _ additional; - lnk = lnk | uri | html; - ''; + lnk = lnk | uri ; + IF target ; + ''; + ELSE; + ''; + END; label | html; ""; END; @@ -56,15 +64,19 @@ 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; ''; 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; ''; @@ -133,7 +145,7 @@ This takes an object and and displays its properties in a table. [% INCLUDE navbar %] - + [% FOR col = classmetadata.columns.list; @@ -149,11 +161,18 @@ from the C method: #%] - +
[% classmetadata.colnames.$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; ''; + 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; %] [%#