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( labels => 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()
Renders ordered <ol> and unordered <ul> lists.
LITERAL PARAMETERS
ordered
-
Boolean. Uses <ol> instead of <ul> container when true.
ordered => 1
col
-
Emit this column. Default 0. (Zero index based.) If neither
col
norrow
are specified then the first column (0) is used.col => 2
row
-
Emit this row. (Zero index based.) If neither
col
norrow
are specified then the first column (0) is used.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()
Renders <select> lists.
LITERAL PARAMETERS
col
-
Emit this column as the texts (always) and the next column as the values (if
labels
is true). Default 0. (Zero index based.) If neitherrow
norcol
is specified, then the first column (0) is used to create the <select> list.col => 2
row
-
Emit this row (zero index based) as the texts (always) and the next row as the values (if
labels
is true). If neitherrow
norcol
is specified, then the first column (0) is used to create the <select> list.row => 0
labels
-
Optional boolean. Uses either the next row or column as the values for the text arguments.
labels => 1
texts
-
Optional array ref of default texts to be initially selected.
texts => [qw( id1 id4 )]
values
-
Optional array ref of default values to be initially selected.
values => [qw( label2 label3 )]
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 oflabels
.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' } }
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 2015 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.