Abstract out the making of label tags from td tags
authorKarl O. Pinc <kop@karlpinc.com>
Tue, 8 Oct 2024 17:17:37 +0000 (12:17 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Tue, 8 Oct 2024 17:17:37 +0000 (12:17 -0500)
src/pgwui_common/templates/lib.mak

index 266b16a786c0bb016b0ce0fd743d3f7ece1dff5d..40a752694adb824221f145136184b79b1563d884 100644 (file)
    % endif
 </%def>
 
+## labels
+
+<%def name="label(for_id='', id='')">
+     % if for_id == '':
+         ${capture(caller.body) | n,trim}:
+     % else:
+         <label ${f'id="{id}"' if id is not None else '' | n}
+                ${f'for="{for_id}"' | n}>${capture(caller.body)
+                                          | n,trim}:</label>
+     % endif
+</%def>
+
 ## Table data
 
-<%def name="td_label(for_id=None, id=None)">
-        <td class="label"
-          % if for_id is not None:
-              ><label ${f'id="{id}"' if id is not None else '' | n}
-                      ${f'for="{for_id}"' | n}>${capture(caller.body)
-                                                | n,trim}:</label></td>
-          % else:
-              >${capture(caller.body) | n, trim}:</td>
-          % endif
+<%def name="td_label(for_id='', id='')">
+        <td class="label"><%self:label for_id="${for_id}" id="${id}"
+          >${capture(caller.body) | n,trim}</%self:label></td>
 </%def>
 
 <%def name="td_input(tab_index, tab_inc=1, colspan=1, clas='')">