Add label_html row option to ui_dl
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled

This commit is contained in:
Ilia Ross
2026-09-30 16:53:05 +02:00
parent 8a09ca5342
commit c8a6a0f69a
2 changed files with 8 additions and 1 deletions

View File

@@ -176,6 +176,8 @@ unlike(main::ui_page_start({ 'scheme' => 'bogus"' }),
{ 'label' => 'Esc', 'value' => '<b>text</b>' } ]);
like($html, qr/<dd[^>]*><b>html<\/b><\/dd>/, 'array row value is HTML');
like($html, qr/&lt;b&gt;text&lt;\/b&gt;/, 'hash row value is escaped');
like(main::ui_dl([ { 'label_html' => '<i>L</i>', 'value' => 'v' } ]),
qr/<dt[^>]*><i>L<\/i><\/dt>/, 'hash row label_html is HTML');
like(main::ui_dl([ [ 'L', 'v', 'tip' ] ]), qr/ui_help/,
'help text uses the existing ui_help bubble');
}

View File

@@ -4897,6 +4897,8 @@ or a hash reference with keys :
=item label - Plain label text.
=item label_html - Pre-built HTML for the label, used instead of label.
=item value - Plain value text, which will be escaped.
=item value_html - Pre-built HTML for the value, used instead of value.
@@ -4924,12 +4926,15 @@ foreach my $row (@$rows) {
next if (!defined($row));
my ($label, $value, $help);
if (ref($row) eq 'HASH') {
$label = &html_escape($row->{'label'});
# Row given as named parts, escaped unless supplied as HTML
$label = defined($row->{'label_html'}) ? $row->{'label_html'}
: &html_escape($row->{'label'});
$value = defined($row->{'value_html'}) ? $row->{'value_html'}
: &html_escape($row->{'value'});
$help = $row->{'help'};
}
else {
# Row given as a [ label, value-html, help ] array
$label = &html_escape($row->[0]);
$value = defined($row->[1]) ? $row->[1] : "";
$help = $row->[2];