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'. * "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($type, $color); Process CSS::Struct structure for output. Variable $type is string which define message type. Possible values 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'); $messages->process_css('info', 'green'); $begin->process; $messages->process($message_ar); $end->process; # Print out. print $tags->flush; # Output: # # #
# # # #