CONTENTS

NAME

YAML::PP::Emitter - Emitting events

SYNOPSIS

my $emitter = YAML::PP::Emitter->new(
    indent => 4,
);

$emitter->init;

$emitter->stream_start_event;
$emitter->document_start_event({ implicit => 1 });
$emitter->sequence_start_event;
$emitter->scalar_event({ value => $input, style => $style });
$emitter->sequence_end_event;
$emitter->document_end_event({ implicit => 1 });
$emitter->stream_end_event;

my $yaml = $emitter->writer->output;
$emitter->finish;

DESCRIPTION

The emitter emits events to YAML. It provides methods for each event type. The arguments are mostly the same as the events from YAML::PP::Parser.

METHODS

new
my $emitter = YAML::PP::Emitter->new(
    indent => 4,
);

Constructor. Currently takes these options:

indent
writer
stream_start_event, stream_end_event, document_start_event, document_end_event, sequence_start_event, sequence_end_event, mapping_start_event, mapping_end_event, scalar_event, alias_event
indent, set_indent

Getter/setter for number of indentation spaces.

TODO: Currently sequences are always zero-indented.

writer, set_writer

Getter/setter for the writer object. By default YAML::PP::Writer. You can pass your own writer if you want to output the resulting YAML yourself.

init

Initialize

finish