NAME
C::Template - Template toolkit for C.
SYNOPSIS
my $ct = C::Template->new ();
$ct->process ("x.c.tmpl", \%vars, "x.c");
DESCRIPTION
This module is a wrapper around Template which adds two filters, c
and cpc
.
METHODS
new
my $ct = C::Template->new ();
Create a new object. This incorporates a Template object. To change the include path,
my $ct = C::Template->new ({include_path => '/path/to/include/files'});
process
$ct->process ('input-template', \%vars, 'output');
This processes input-template
into output
. output
is normally a C file. If the input contains a line
#line
it will be processed into "#line 4" with the line number added.
FILTERS
c
In the Perl program:
$vars{stuff} = 'test "string" 100%'
In the template:
[% stuff | c %]
Output is
"test \"string\" 100%"
The c
filter changes its input into a C string. Percentage signs '%' are not changed.
cpc
In the Perl program:
$vars{stuff} = 'test "string" 100%'
In the template:
[% stuff | cpc %]
Output is
"test \"string\" 100%%"
The cpc
filter changes its input into a C string. Percentage signs are changed from '%' to '%%' so that the string can be used as the format argument for printf-style functions without interpolation of arguments.
AUTHOR AND COPYRIGHT
Ben Bullock, <bkb@cpan.org>, copyright (c) 2012-2014
LICENCE
This may be used, redistributed, and modified under the same terms as Perl itself.