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); $obj->process_css($type, $color); METHODS "new" my $obj = Tags::HTML::Messages->new(%params); Constructor. * "css" 'CSS::Struct::Output' object for process_css processing. Default value is undef. * "css_messages" CSS class for main messages div block. Default value is 'messages'. * "flag_no_messages" Flag for no messages printing. Possible values: 0 - Print nothing 1 - Print message box with 'No messages.' text. Default value is 1. * "tags" 'Tags::Output' object. Default value is undef. "process" $obj->process($message_ar); Process Tags structure for output. Reference to array with message objects $message_ar must be a instance of Data::Message::Simple object. Returns undef. "process_css" $obj->process_css($message_types_hr); Process CSS::Struct structure for output. Variable $message_type_hr is reference to hash with keys for message type and value for color in CSS style. Possible message types are info and error now. Types are defined in Data::Message::Simple. Returns undef. ERRORS new(): From Class::Utils::set_params(): Unknown parameter '%s'. Parameter 'css' must be a 'CSS::Struct::Output::*' class. Parameter 'tags' must be a 'Tags::Output::*' class. process(): Bad list of messages. Bad message data object. EXAMPLE1 use strict; use warnings; use CSS::Struct::Output::Indent; use Data::Message::Simple; 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, 'lang' => { 'title' => 'Tags::HTML::Messages example', }, 'generator' => 'Tags::HTML::Messages', 'tags' => $tags, ); my $end = Tags::HTML::Page::End->new( 'tags' => $tags, ); my $messages = Tags::HTML::Messages->new( 'css' => $css, 'tags' => $tags, ); # Error structure. my $message_ar = [ Data::Message::Simple->new( 'text' => 'Error #1', 'type' => 'error', ), Data::Message::Simple->new( 'text' => 'Error #2', 'type' => 'error', ), Data::Message::Simple->new( 'text' => 'Ok #1', ), Data::Message::Simple->new( 'text' => 'Ok #2', ), ]; # Process page. $messages->process_css({ 'error' => 'red', 'info' => 'green', }); $begin->process; $messages->process($message_ar); $end->process; # Print out. print $tags->flush; # Output: # # # # # # # # Tags::HTML::Messages example # # # # #
# # Error #1 # #
# # Error #2 # #
# # Ok #1 # #
# # Ok #2 # #
# # DEPENDENCIES Class::Utils, Error::Pure, Scalar::Util, Tags::HTML. REPOSITORY AUTHOR Michal Josef Špaček LICENSE AND COPYRIGHT © Michal Josef Špaček 2020-2023 BSD 2-Clause License VERSION 0.06