NAME
Spreadsheet::HTML::Presets::List - Generate <select>, <ol> and <ul> lists.
DESCRIPTION
This is a container for Spreadsheet::HTML preset methods. These methods are not meant to be called from this package. Instead, use the Spreadsheet::HTML interface:
use Spreadsheet::HTML;
my $generator = Spreadsheet::HTML->new( data => \@data );
print $generator->list( ordered => 1 );
print $generator->select( values => 1, placeholder => 'Pick one' );
# or
use Spreadsheet::HTML qw( list );
print list( data => \@data, col => 2 );
print Spreadsheet::HTML::select( data => \@data, row => 0 );
Note that select()
is not exportable, due to the existance of Perl's built-in select()
function.
METHODS
list( ordered, col, row, %params )
Renders ordered <ol> and unordered <ul> lists.
LITERAL PARAMETERS
headless
Boolean. Discard first element. Useful for datasets that include headings.
headless => 1
ordered
Boolean. Uses <ol> instead of <ul> container when true.
ordered => 1
col
Integer. Start at this column. If neither
col
norrow
is specified, then the first column (0) is used.col => 2
row
Integer. Start at this row. If neither
row
norcol
is specified, then the first column (0) is used (not the first row).row => 0
TAG PARAMETERS
ol
Hash reference of attributes.
ol => { class => 'list' }
ul
Hash reference of attributes.
ul => { class => 'list' }
li
Accepts hash reference, sub reference, or array ref containing either or both.
li => { class => [qw( odd even )] } li => sub { ucfirst shift } li => [ { class => 'item' }, sub { sprintf '%2d', shift } ]
select( col, row, values, selected, placeholder, optgroup, label, %params )
Renders <select> lists.
LITERAL PARAMETERS
headless
Discard first element. Useful for datasets that include headings.
headless => 1
col
Integer. Start at this column. If neither
col
norrow
is specified, then the first column (0) is used.col => 2
row
Integer. Start at this row. If neither
row
norcol
is specified, then the first column (0) is used (not the first row).row => 0
values
Optional boolean. Default false. The selected
row
orcol
will be used as the <option> tags' CDATA value.values => 0
When set to true the selected
col
orrow
will be used as the <option> tags' 'value' attribute and the NEXTcol
orrow
(respectively) will be used as the <option> tags' CDATA value.values => 1
selected
Optional scalar or array ref of default <option> CDATA values (if
values
is false>) or <option> 'value' attributes (ifvalues
is true) to be initially selected.selected => 'id1' selected => [qw( id1 id4 )]
placeholder
Optional string. Inserts the
placeholder
as the first <option> in the <select> list. This <option> will always have a value attribute set to empty string regardless of the value ofvalues
.placeholder => 'Please select an option'
label
Emits <label> tag for list. Either a scalar string or a special hash ref whose only key is the CDATA for the <label> and the only value is the attributes as a hash ref.
label => 'Label with no attributes' label => { 'Label with attributes' => { class => 'label' } }
optgroup
Optional array ref of scalars.
optgroup => [ 'Group 1:', 'Group 2:', 'Group 3:' ]
TAG PARAMETERS
select
Hash reference of attributes.
select => { class => 'select' }
option
Accepts hash reference, sub reference, or array ref containing either or both.
option => { class => [qw( odd even )] } option => sub { uc shift } option => [ sub { uc shift }, { class => [qw( odd even )] } ]
SEE ALSO
- Spreadsheet::HTML
-
The interface for this functionality.
- Spreadsheet::HTML::Presets
-
More presets.
- http://www.w3.org/TR/html5/forms.html
AUTHOR
Jeff Anderson, <jeffa at cpan.org>
LICENSE AND COPYRIGHT
Copyright 2024 Jeff Anderson.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.