NAME
Stencil::Source
ABSTRACT
Source generator base class
SYNOPSIS
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);
DESCRIPTION
This package provides a source generator base class and is meant to be extended.
LIBRARIES
This package uses type constraints from:
ATTRIBUTES
This package has the following attributes:
data
data(Object)
This attribute is read-only, accepts (Object)
values, and is optional.
repo
repo(Object)
This attribute is read-only, accepts (Object)
values, and is optional.
METHODS
This package implements the following methods:
make
make(HashRef $oper, HashRef $vars) : InstanceOf["Path::Tiny"]
The make method executes the instructions, then returns the file.
- make example #1
-
# given: synopsis $source->make({ from => 'class', make => 'MyApp.pm' }, { name => 'MyApp' });
process
process(Str $text, HashRef $vars, Str $file) : InstanceOf["Path::Tiny"]
The process method renders the template, then creates and returns the file.
- process example #1
-
# given: synopsis $source->process('use [% data.name %]', { name => 'MyApp' }, 'example.pl');
render
render(Str $text, HashRef $vars) : Str
The render method processes the template and returns the content.
template
template(Str $name) : Str
The template method returns the named content declared in the __DATA__
section of the generator.
AUTHOR
Al Newkirk, awncorp@cpan.org
LICENSE
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".