Stencil::Source
Source generator base class
use Stencil::Repo; use Stencil::Source::Test; my $repo = Stencil::Repo->new; $repo->store->mkpath; my $source = Stencil::Source::Test->new; # $source->make($oper, $data);
This package provides a source generator base class and is meant to be extended.
This package uses type constraints from:
Types::Standard
This package has the following attributes:
data(Object)
This attribute is read-only, accepts (Object) values, and is optional.
(Object)
repo(Object)
This package implements the following methods:
make(HashRef $oper, HashRef $vars) : InstanceOf["Path::Tiny"]
The make method executes the instructions, then returns the file.
# given: synopsis $source->make({ from => 'class', make => 'MyApp.pm' }, { name => 'MyApp' });
process(Str $text, HashRef $vars, Str $file) : InstanceOf["Path::Tiny"]
The process method renders the template, then creates and returns the file.
# given: synopsis $source->process('use [% data.name %]', { name => 'MyApp' }, 'example.pl');
render(Str $text, HashRef $vars) : Str
The render method processes the template and returns the content.
# given: synopsis $source->render('use [% data.name %]', { name => 'MyApp' });
template(Str $name) : Str
The template method returns the named content declared in the __DATA__ section of the generator.
__DATA__
# given: synopsis $source->template('class');
# given: synopsis $source->template('class-test');
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install Stencil, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Stencil
CPAN shell
perl -MCPAN -e shell install Stencil
For more information on module installation, please visit the detailed CPAN module installation guide.