The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Stenciller::Transformer - A role for transformer plugins to consume

VERSION

Version 0.1400, released 2016-02-03.

SYNOPSIS

    package Stenciller::Plugin::MyNewRenderer;

    use Moose;
    with 'Stenciller::Transformer';

    sub transformer {
        ...
    }

DESCRIPTION

This is the role that all Stenciller plugins must consume. It requires a transformer method to be implemented.

METHODS

transform

This method must be implemented by classes consuming this role.

It takes one attribute:

$transform_args

$transform_args is a hash reference with the following structure:

    $transform_args => {
        skip_header_lines => 0|1,
        stencils => [...],
        require_in_extra => {
            key => '...',
            value => '...',
            default => '...',
        },
    }

skip_header_lines => 1

skip_header_lines takes a boolean indicating if the Stenciller's header_lines should be skipped. Default is 0.

stencils => [ ]

stencils takes an array reference of which stencils in the currently parsed file that should be included in the output. The index is zero based. If stencils is not given, all stencils are parsed.

require_in_extra => { }

require_in_extra allows finer filtering than stencils. Usually, the point to using Stenciller, and related modules, is to use the same content more than once (eg. include it in pod, create html files with examples, and create tests). It is not always necessary to include every stencil in every end product.

If require_in_extra is given, it looks in the options hash for every stencil for the key key.

  • If key exists in the stencil's hash, and it has the value value, then the stencil is parsed.

  • If key exists in the stencil's hash, and it doesn't have the value value, then the stencil is not parsed.

  • If key doesn't exist in the stencil's hash, then the two first rules are applied as if the stencil had the default value.

ATTRIBUTES

stenciller

The Stenciller object is passed automatically to plugins.

SOURCE

https://github.com/Csson/p5-Stenciller

HOMEPAGE

https://metacpan.org/release/Stenciller

AUTHOR

Erik Carlsson <info@code301.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Erik Carlsson.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.