Piffle::Template 0.3.1 review

Download
by rbytes.net on

Piffle::Template is a Perlish templating language. SYNOPSIS use Piffle::Template; use Piffle::Template qw{template_to_

License: Perl Artistic License
File size: 9K
Developer: Andrew Chadwick
0 stars award from rbytes.net

Piffle::Template is a Perlish templating language.

SYNOPSIS

use Piffle::Template;
use Piffle::Template qw{template_to_perl expand_template};

# OO syntax, with output stored and returned:
print Piffle::Template->expand(source_file => 'foo/fish.xml',
include_path => ['foo/inc','foo']);

# Immediate: OO syntax: output goes directly to STDOUT:
Piffle::Template->expand(source_file => 'foo/fish.xml',
output_file => *STDOUT);

# Procedural syntax, data from a string
$string =
< ?perl } ? >
< ?include std_disclaimer.txt? >
__END__
expand_template(source => $string,
output_file => *FILE);

This is a simple Perl-embedding syntax for template code which is geared towards allowing authors to validate their templates directly against schemas or DTDs. The embedded language is Perl itself, which allows great flexibility at the expense of having to be disciplined about the barrier between template code and module code.

In operation, the source template is transformed to an in-memory Perl script which is then run using Perl's eval operator. Errors can be redirected to files or subroutines, and the output can be either caught in a variable or written to a file or open filehandle.

Requirements:
Perl

Piffle::Template 0.3.1 search tags