Tags::Output::Raw - Raw printing 'Tags' structure to tags code.
use Tags::Output::Raw; my $tags = Tags::Output::Raw->new(%params); $tags->put(['b', 'tag']); my @open_tags = $tags->open_tags; $tags->finalize; $tags->flush($reset_flag); $tags->reset;
new(%params)
Constructor.
attr_callback
Subroutine for output processing of attribute key and value. Input argument is reference to array. Default value is &Tags::Utils::encode_attr_entities. Example is similar as 'data_callback'.
attr_delimeter
String, that defines attribute delimeter. Default is '"'. Possible is '"' or "'". Example: Prints <tag attr='val' /> instead default <tag attr="val" /> my $tags = Tags::Output::Raw->new( 'attr_delimeter' => "'", ); $tags->put(['b', 'tag'], ['a', 'attr', 'val'], ['e', 'tag']); $tags->flush;
auto_flush
Auto flush flag. Default is 0.
cdata_callback
Subroutine for output processing of cdata. Input argument is reference to array. Default value is undef. Example is similar as 'data_callback'.
data_callback
Subroutine for output processing of data. Input argument is reference to array. Default value is &Tags::Utils::encode_char_entities. Example: 'data_callback' => sub { my $data_ar = shift; foreach my $data (@{$data_ar}) { # Some process. $data =~ s/^\s*//ms; } return; }
no_simple
Reference to array of tags, that can't by simple. Default is []. Example: That's normal in html pages, web browsers has problem with <script /> tag. Prints <script></script> instead <script />. my $tags = Tags::Output::Raw->new( 'no_simple' => ['script'], ); $tags->put(['b', 'script'], ['e', 'script']); $tags->flush;
output_callback
Output callback. Input argument is reference to scalar of output string. Default value is undef. Example for output encoding in utf8: 'output_callback' => sub { my $data_sr = shift; ${$data_sr} = encode_utf8(${$data_sr}); return; }
output_handler
Handler for print output strings. Must be a GLOB. Default is undef.
preserved
List of elements, which content will be preserved. Default value is reference to blank array.
raw_callback
Subroutine for output processing of raw data. Input argument is reference to array. Default value is undef. Example is similar as 'data_callback'.
skip_bad_tags
Skip bad tags. Default value is 0.
strict_instruction
Strict instruction. Default value is 1.
xml
Flag, that means xml output. Default is 0 (sgml).
finalize()
Finalize Tags output. Automaticly puts end of all opened tags. Returns undef.
flush($reset_flag)
Flush tags in object. If defined 'output_handler' flush to its. Or return code. If enabled $reset_flag, then resets internal variables via reset method.
open_tags()
Return array of opened tags.
put(@data)
Put tags code in tags format. Returns undef.
reset()
Resets internal variables. Returns undef.
new(): Bad attribute delimeter '%s'. From Tags::Output::new(): Auto-flush can't use without output handler. Output handler is bad file handler. From Class::Utils::set_params(): Unknown parameter '%s'. flush(): From Tags::Output::flush(): Cannot write to output handler. put(): Bad tag type 'a'. Bad CDATA data. Ending bad tag: '%s' doesn't begin. Ending bad tag: '%s' in block of tag '%s'. In XML mode must be a attribute '%s' value. In XML must be lowercase tag name. From Tags::Output::put(): Bad data. Bad type of data. Bad number of arguments. 'Tags' structure %s
use strict; use warnings; use Tags::Output::Raw; # Object. my $tags = Tags::Output::Raw->new; # Put data. $tags->put( ['b', 'text'], ['d', 'data'], ['e', 'text'], ); # Print. print $tags->flush."\n"; # Output: # <text>data</text>
use strict; use warnings; use Encode; use Tags::Output::Raw; # Object. my $tags = Tags::Output::Raw->new( 'data_callback' => sub { my $data_ar = shift; foreach my $data (@{$data_ar}) { $data = encode_utf8($data); } return; }, ); # Data in characters. my $data = decode_utf8('řčěšřšč'); # Put data. $tags->put( ['b', 'text'], ['d', $data], ['e', 'text'], ); # Print. print $tags->flush."\n"; # Output: # <text>řčěšřšč</text>
Error::Pure, List::MoreUtils, Readonly, Tags::Utils::Preserve.
Install the Tags modules.
https://github.com/tupinek/Tags
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz/
© 2005-2018 Michal Josef Špaček BSD 2-Clause License
0.07
To install Tags, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tags
CPAN shell
perl -MCPAN -e shell install Tags
For more information on module installation, please visit the detailed CPAN module installation guide.