NAME

IPC::PrettyPipe::Render::Template::Tiny - rendering backend using Template::Tiny

VERSION

version 0.06

SYNOPSIS

use IPC::PrettyPipe::DSL;

my $pipe = ppipe 'ls';
$pipe->renderer( 'Template::Tiny' );

# or, more explicitly
my $renderer = IPC::PrettyPipe::Render::Template::Tiny->new;
$pipe->renderer( $renderer );

DESCRIPTION

IPC::PrettyPipe::Render::Template::Tiny implements the IPC::PrettyPipe::Renderer role, providing a rendering backend for IPC::PrettyPipe using the Template::Tiny module.

METHODS

new
$renderer = IPC::PrettyPipe::Render::Template::Tiny->new( %attr );

Construct a new renderer. Typically this is done automatically by IPC::PrettyPipe. The following attributes are available:

pipe

The IPC::PrettyPipe object to render.

colors

A color specification; see "Rendered Colors".

template

A Template::Tiny template to generate the output. See "Rendering Template".

render
$renderer->render( %options );

The following options are available:

  • colorize

    If true (the default) the output is colorized using Term::AnsiColor.

pipe
$pipe = $renderer->pipe;
$renderer->pipe( $pipe );

Retrieve or set the IPC::PrettyPipe object to render.

colors
$colors = $renderer->colors;
$renderer->colors( $colors );

Retrieve or set the colors to be output; see "Rendered Colors".

template
$template = $renderer->template;
$renderer->template( $template );

Retrieve or set the Template::Tiny template used to generate the output. See "Rendering Template".

CONFIGURATION

Rendering Template

The template attribute and method may be used to change the template used to render the pipeline. The template is passed the following parameters:

pipe

pipe is the IPC::PrettyPipe object. Template::Tiny doesn't support loop constructs, so the IPC::PrettyPipe streams and cmds methods return IPC::PrettyPipe::Queue objects, which provide methods for determining if the lists are empty.

[% IF pipe.streams.empty %][% ELSE %](\t\\
[% END -%]

Note that Template::Tiny resolves object methods with the same syntax as it resolves hash entries.

Iteration looks like this:

[%- FOREACH cmd IN pipe.cmds.elements %]
[% END %]

An IPC::PrettyPipe::Queue::Element has additional methods which indicates whether it is the first or last in its queue.

[%- IF cmd.first %]  [% ELSE %]\t\\
| [% END %]
color

This is the hashref specified by the colors attribute or method. It contains an additional element reset which can be used to reset all colors at once. Here's an example bit of template to output and colorize a command:

[% color.cmd.cmd %][% cmd.cmd %][% color.reset %]

The default template (encoded into the source file for IPC::PrettyPipe::Render::Template::Tiny) provides a good example of how to construct one.

Rendered Colors

The colors attribute and method may be used to change the colors used to render the pipeline. Colors are stored as a hashref with the following default contents:

cmd => {
    cmd    => 'blue',
    stream => {
        spec => 'red',
        file => 'green',
    },
    arg => {
        name  => 'red',
        sep   => 'yellow',
        value => 'green',
    },
},
pipe => {
    stream => {
        spec => 'red',
        file => 'green',
    },
},

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=IPC-PrettyPipe or by email to bug-IPC-PrettyPipe@rt.cpan.org.

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SOURCE

The development version is on github at https://github.com/djerius/ipc-prettypipe and may be cloned from git://github.com/djerius/ipc-prettypipe.git

SEE ALSO

Please see those modules/websites for more information related to this module.

AUTHOR

Diab Jerius <djerius@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.

This is free software, licensed under:

The GNU General Public License, Version 3, June 2007