Data::HTML::Button - Data object for HTML button element.
use Data::HTML::Button; my $obj = Data::HTML::Button->new(%params); my $autofocus = $obj->autofocus; my $css_class = $obj->css_class; my $data = $obj->data; my $data_type = $obj->data_type; my $disabled = $obj->disabled; my $form = $obj->form; my $form_enctype = $obj->form_enctype; my $form_method = $obj->form_method; my $id = $obj->id; my $label = $obj->label; my $name = $obj->name; my $type = $obj->type; my $value = $obj->value;
new
my $obj = Data::HTML::Button->new(%params);
Constructor.
Returns instance of object.
autofocus
Button autofocus flag.
Default value is 0.
css_class
Button CSS class.
Default value is undef.
data
Button data content. It's reference to array. Data type of data is described in 'data_type' parameter.
Default value is [].
data_type
Button data type for content.
Possible value are: plain tags
Default value is 'plain'.
disabled
form
Button form id.
form_enctype
Button form encoding. It's valuable for 'submit' type.
Possible values are: application/x-www-form-urlencoded multipart/form-data text/plain
form_method
Button form method. It's valuable for 'submit' type.
Possible values are: get post
Default value is 'get'.
id
Button identifier.
label
Button label.
name
Button name.
type
Button element type.
Possible types: button reset submit
Default value is 'button'.
value
Button value.
my $autofocus = $obj->autofocus;
Get button autofocus flag.
Returns bool value (1/0).
my $css_class = $obj->css_class;
Get CSS class for button.
Returns string.
my $data = $obj->data;
Get data inside button element.
Returns reference to array.
my $data_type = $obj->data_type;
Get button data type.
my $disabled = $obj->disabled;
Get button disabled flag.
my $form = $obj->form;
Get button form id.
my $form_enctype = $obj->form_enctype;
Get button form enctype.
my $form_method = $obj->form_method;
Get button form method.
my $id = $obj->id;
Get button identifier.
my $label = $obj->label;
Get button label.
my $name = $obj->name;
Get button name.
my $type = $obj->type;
Get button type.
my $value = $obj->value;
Get button value.
new(): Parameter 'autofocus' must be a bool (0/1). Value: %s Parameter 'data_type' has bad value. Parameter 'disabled' must be a bool (0/1). Value: %s Parameter 'form_enctype' has bad value. Value: %s Parameter 'form_method' has bad value. Parameter 'type' has bad value.
use strict; use warnings; use Data::HTML::Button; my $obj = Data::HTML::Button->new; # Print out. print 'Data type: '.$obj->data_type."\n"; print 'Form method: '.$obj->form_method."\n"; print 'Type: '.$obj->type."\n"; # Output: # Data type: plain # Form method: get # Type: button
use strict; use warnings; use Data::HTML::Button; use Tags::Output::Raw; my $obj = Data::HTML::Button->new( # Tags(3pm) structure. 'data' => [ ['b', 'span'], ['d', 'Button'], ['e', 'span'], ], 'data_type' => 'tags', ); my $tags = Tags::Output::Raw->new; # Serialize data to output. $tags->put(@{$obj->data}); my $data = $tags->flush(1); # Print out. print 'Data (serialized): '.$data."\n"; print 'Data type: '.$obj->data_type."\n"; print 'Form method: '.$obj->form_method."\n"; print 'Type: '.$obj->type."\n"; # Output: # Data (serialized): <span>Button</span> # Data type: tags # Form method: get # Type: button
use strict; use warnings; use Data::HTML::Button; my $obj = Data::HTML::Button->new( # Plain content. 'data' => [ 'Button', ], 'data_type' => 'plain', ); # Serialize data to output. my $data = join ' ', @{$obj->data}; # Print out. print 'Data: '.$data."\n"; print 'Data type: '.$obj->data_type."\n"; print 'Form method: '.$obj->form_method."\n"; print 'Type: '.$obj->type."\n"; # Output: # Data: Button # Data type: plain # Form method: get # Type: button
Error::Pure, List::Util, Mo, Mo::utils, Readonly.
https://github.com/michal-josef-spacek/Data-HTML-Button
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© 2022 Michal Josef Špaček
BSD 2-Clause License
0.01
To install Data::HTML::Button, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::HTML::Button
CPAN shell
perl -MCPAN -e shell install Data::HTML::Button
For more information on module installation, please visit the detailed CPAN module installation guide.