NAME

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

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 renderding 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',
    },
},

COPYRIGHT & LICENSE

Copyright 2013 Smithsonian Astrophysical Observatory

This software is released under the GNU General Public License. You may find a copy at

http://www.fsf.org/copyleft/gpl.html

AUTHOR

Diab Jerius <djerius@cfa.harvard.edu>