NAME

Tags::HTML::Element::Button - Tags helper for HTML button element.

SYNOPSIS

use Tags::HTML::Element::Button;

my $obj = Tags::HTML::Element::Button->new(%params);
$obj->cleanup;
$obj->init($button);
$obj->prepare;
$obj->process;
$obj->process_css;

METHODS

new

my $obj = Tags::HTML::Element::Button->new(%params);

Constructor.

cleanup

$obj->cleanup;

Process cleanup after page run.

In this case cleanup internal representation of button set by init.

Returns undef.

init

$obj->init($button);

Process initialization in page run.

Accepted $button is Data::HTML::Element::Button.

Returns undef.

prepare

$obj->prepare;

Process initialization before page run.

Do nothing in this object.

Returns undef.

process

$obj->process;

Process Tags structure for HTML button element to output.

Do nothing in case without inicialization by init.

Returns undef.

process_css

$obj->process_css;

Process CSS::Struct structure for HTML button element to output.

Do nothing in case without inicialization by init.

Returns undef.

ERRORS

new():
        From Tags::HTML::new():
                Parameter 'css' must be a 'CSS::Struct::Output::*' class.
                Parameter 'tags' must be a 'Tags::Output::*' class.
        Input object must be a 'Data::HTML::Element::Button' instance.

process():
        From Tags::HTML::process():
                Parameter 'tags' isn't defined.

process_css():
        From Tags::HTML::process_css():
                Parameter 'css' isn't defined.

EXAMPLE

use strict;
use warnings;

use CSS::Struct::Output::Indent;
use Data::HTML::Element::Button;
use Tags::HTML::Element::Button;
use Tags::Output::Indent;

# Object.
my $css = CSS::Struct::Output::Indent->new;
my $tags = Tags::Output::Indent->new(
        'xml' => 1,
);
my $obj = Tags::HTML::Element::Button->new(
        'css' => $css,
        'tags' => $tags,
);

# Data object for button.
my $button = Data::HTML::Element::Button->new(
        'css_class' => 'button',
);

# Initialize.
$obj->init($button);

# Process button.
$obj->process;
$obj->process_css;

# Print out.
print "HTML:\n";
print $tags->flush;
print "\n\n";
print "CSS:\n";
print $css->flush;

# Output:
# HTML:
# <button type="button" class="button" />
#
# CSS:
# button.button {
#         width: 100%;
#         background-color: #4CAF50;
#         color: white;
#         padding: 14px 20px;
#         margin: 8px 0;
#         border: none;
#         border-radius: 4px;
#         cursor: pointer;
# }
# button.button:hover {
#         background-color: #45a049;
# }

DEPENDENCIES

Class::Utils, Error::Pure, Scalar::Util, Tags::HTML, Tags::HTML::Element::Utils.

REPOSITORY

https://github.com/michal-josef-spacek/Tags-HTML-Element

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

© 2022-2024 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.13