NAME
Tags::HTML::Messages - Tags helper for HTML messages.
SYNOPSIS
use Tags::HTML::Messages;
my $obj = Tags::HTML::Messages->new(%params);
$obj->process($message_ar, $id);
$obj->process_css($id, $color);
METHODS
new
my $obj = Tags::HTML::Messages->new(%params);
Constructor.
css
'CSS::Struct::Output' object for process_css processing.
It's required.
Default value is undef.
tags
'Tags::Output' object.
It's required.
Default value is undef.
process
$obj->process($message_ar, $id);
Process Tags structure for output.
Returns undef.
process_css
$obj->process_css($id, $color);
Process CSS::Struct structure for output.
Returns undef.
ERRORS
new():
Parameter 'css' must be a 'CSS::Struct::Output::*' class.
Parameter 'tags' must be a 'Tags::Output::*' class.
From Class::Utils::set_params():
Unknown parameter '%s'.
EXAMPLE1
use strict;
use warnings;
use CSS::Struct::Output::Indent;
use Tags::HTML::Page::Begin;
use Tags::HTML::Page::End;
use Tags::HTML::Messages;
use Tags::Output::Indent;
# Object.
my $tags = Tags::Output::Indent->new(
'preserved' => ['style'],
'xml' => 1,
);
my $css = CSS::Struct::Output::Indent->new;
my $begin = Tags::HTML::Page::Begin->new(
'css' => $css,
'tags' => $tags,
);
my $end = Tags::HTML::Page::End->new(
'tags' => $tags,
);
my $messages = Tags::HTML::Messages->new(
'css' => $css,
'tags' => $tags,
);
# Error structure.
my $error_messages_ar = [
'Error #1',
'Error #2',
];
my $ok_messages_ar = [
'Ok #1',
'Ok #2',
];
# Process page.
$messages->process_css('error', 'red');
$messages->process_css('ok', 'green');
$begin->process;
$messages->process($error_messages_ar, 'error');
$messages->process($ok_messages_ar, 'ok');
$end->process;
# Print out.
print $tags->flush;
# Output:
# <!DOCTYPE html>
# <html>
# <head>
# <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
# <title>
# Page title
# </title>
# <style type="text/css">
# #error {
# color: red;
# }
# #ok {
# color: green;
# }
# </style>
# </head>
# <body>
# <span id="error">
# Error #1
# </span>
# <span id="error">
# Error #2
# </span>
# <span id="ok">
# Ok #1
# </span>
# <span id="ok">
# Ok #2
# </span>
# </body>
# </html>
DEPENDENCIES
REPOSITORY
https://github.com/michal-josef-spacek/Tags-HTML-Messages
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© Michal Josef Špaček 2020
BSD 2-Clause License
VERSION
0.02