Stenciller - Transforms a flat file format to different output
Version 0.1400, released 2016-02-03.
use Stenciller;
my $stenciller = Stenciller->new(filepath => 't/corpus/test-1.stencil');
my $content = $stenciller->transform(plugin_name => 'ToUnparsedText');
Stenciller reads a special fileformat and provides a way to convert the content into different types of output. For example, it can be used to create documentation and tests from the same source file.
== stencil {} ==
--input--
--end input--
--output--
--end output--
This is the basic layout. A stencil ends when a new stencil block is discovered (there is no fixed limit to the number of stencils in a file). The (optional) hash is for settings. Each stencil has five parts: before_input
, input
, between
, output
and after_output
. In addition to this
there is a header before the first stencil.
File | required | read-only |
The textfile to parse.
Bool | optional, default: 1 |
read-only |
Determines how the stencil file is read.
Bool | optional, default: 1 |
read-only |
If a stencil has no input content, skip entire stencil.
Bool | optional, default: 1 |
read-only |
If a stencil has no output content, skip entire stencil.
ArrayRef [ Str ] | not in constructor | read-only |
After parsing, this contains all lines in the header.
ArrayRef [ Stencil ] | not in constructor | read-only |
After parsing, this contains all parsed stencils.
$stenciller->transform(
plugin_name => 'ToUnparsedText',
constructor_args => {
plugin_specific_args => ...,
},
tranform_args => {
transformation_specific_args => ...,
},
);
plugin_name
is mandatory and should be a class under the Stenciller::Plugin
namespace.
constructor_args
is optional. This hash reference will be passed on to the plugin constructor. Valid keys depends on the plugin.
transform_args
is optional. This hash reference will be passed on to the transform
method in the plugin. Valid keys depends on the plugin.
The actual transforming is done by plugins. There are two plugins bundled in this distribution:
- Stenciller::Plugin::ToUnparsedText
- Stenciller::Plugin::ToHtmlPreBlock
- Pod::Elemental::Transformer::Stenciller
Custom plugins should be in the Stenciller::Plugin namespace and consume the Stenciller::Transformer role.
https://github.com/Csson/p5-Stenciller
https://metacpan.org/release/Stenciller
Erik Carlsson info@code301.com
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.