mirror of
https://github.com/webmin/webmin.git
synced 2026-10-01 01:40:39 +01:00
Add label_html row option to ui_dl
This commit is contained in:
@@ -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/<b>text<\/b>/, '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');
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user