EJS::Template::IO - Mix-in module to normalize input/output parameters for EJS::Template
Normalizes input.
$self->input('filepath.ejs'); $self->input(\$source_text); $self->input($input_handle); $self->input(\*STDIN);
It returns a list in the form ($input, $should_close), where $input is the normalized input handle and $should_close indicates the file handle has been opened and your code is responsible for closing it.
($input, $should_close)
$input
$should_close
Alternatively, a callback can be given as the second argument, which will be invoked with its argument set to the normalized $input.
$self->input('filepath.ejs', sub { my ($input) = @_; while (<$input>) { ... } });
If $input is a file handle that has been opened by this input() method, then it will be closed automatically after the callback returns. Even if die() is invoked within the callback, the file handle will be closed if necessary, and then this input() method will forward die($@).
input()
die()
die($@)
Normalizes output.
$self->output('filepath.out'); $self->output(\$result_text); $self->output($output_handle); $self->output(\*STDOUT);
It returns a list in the form ($output, $should_close), where $output is the normalized output handle and $should_close indicates the file handle has been opened and your code is responsible for closing it.
($output, $should_close)
$output
Alternatively, a callback can be given as the second argument, which will be invoked with its argument set to the normalized $output.
$self->output('filepath.out', sub { my ($output) = @_; while (<$output>) { ... } });
If $output is a file handle that has been opened by this output() method, then it will be closed automatically after the callback returns. Even if die() is invoked within the callback, the file handle will be closed if necessary, and then this output() method will forward die($@).
output()
Prints text to the current output target.
It can be invoked only within an execution context where the output file handle is open.
$self->output('filepath.out', sub { $self->print(...); });
EJS::Template
To install EJS::Template, copy and paste the appropriate command in to your terminal.
cpanm
cpanm EJS::Template
CPAN shell
perl -MCPAN -e shell install EJS::Template
For more information on module installation, please visit the detailed CPAN module installation guide.