C::Template - Template toolkit for C.
my $ct = C::Template->new (); $ct->process ("x.c.tmpl", \%vars, "x.c");
This module is a wrapper around Template which adds two filters, c and cpc.
c
cpc
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'});
$ct->process ('input-template', \%vars, 'output');
This processes input-template into output. output is normally a C file. If the input contains a line
input-template
output
#line
it will be processed into "#line 4" with the line number added.
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.
[% stuff | cpc %]
"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.
Ben Bullock, <bkb@cpan.org>, copyright (c) 2012-2014
This may be used, redistributed, and modified under the same terms as Perl itself.
To install C::Template, copy and paste the appropriate command in to your terminal.
cpanm
cpanm C::Template
CPAN shell
perl -MCPAN -e shell install C::Template
For more information on module installation, please visit the detailed CPAN module installation guide.