App-TypecastTemplates

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

Build.PL
Changes
lib/App/TypecastTemplates.pm
MANIFEST			This list of files
MANIFEST.SKIP
META.json
META.yml
README
t/00-load.t
t/csv/catch-all.csv
t/csv/escape.csv
t/csv/fix.csv
t/csv/without-columns.csv
t/manifest.t
t/pod-coverage.t
t/pod.t
t/script-create_loginrc.t
t/template/catch-all.tmpl
t/template/escape.tmpl
t/template/fix.tmpl
t/template/name-text.tmpl
xt/boilerplate.t

bin/create_cloginrc  view on Meta::CPAN


The CSV file may have arbitrary columns
as long as there is a column named I<< type >>,
which is used to switch between different templates,
and a column for every variable used in the templates.

The column names should either be given in the first line of the CSV file
or with the command line options C<< --columns >>
separated by comma and in the same order as the columns of the CSV file.

If the output of some template variables needs escape sequences
as for instances the .cloginrc file for RANCID
for left and right braces, space, ampersand and backslash
the escape sequence should be given in the CSV file.

=head2 Templates

The templates are a list of text lines
that start with a typename followed by a colon and some text
which is expanded with the Template Toolkit.

For each input line of the CSV file
template lines corresponding to the value of the I<< type >> column
are expanded by the Template Toolkit

t/script-create_loginrc.t  view on Meta::CPAN


$cmd = join(" ", $perl, $lib, $script, "--templatefile=t/template/fix.tmpl",
        "t/csv/fix.csv");
if (open(my $out, '-|', $cmd)) {
        undef $/;
        $text = <$out>;
        close $out;
}
is($text,"Fix Template\n","use fix.tmpl");

$cmd = join(" ", $perl, $lib, $script, "--templatefile=t/template/escape.tmpl",
        "t/csv/escape.csv");
if (open(my $out, '-|', $cmd)) {
        undef $/;
        $text = <$out>;
        close $out;
}
is($text,"escaped {a\\\{\\ \\}\\\&\\\\} (rancid)\n","use fix.tmpl");

$cmd = join(" ", $perl, $lib, $script, "--templatefile=t/template/catch-all.tmpl",
        "t/csv/catch-all.csv");
if (open(my $out, '-|', $cmd)) {
        undef $/;
        $text = <$out>;
        close $out;
}
is($text,"n1's type (known) is known.\nn2's type (unknown) has no template.\n",
	"unknown type");

t/template/escape.tmpl  view on Meta::CPAN

rancid:escaped {[% value %]} ([% type %])



( run in 1.833 second using v1.01-cache-2.11-cpan-7fcb06a456a )