.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Text::Template::Preprocess 3pm" .TH Text::Template::Preprocess 3pm "2019-03-01" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Text::Template::Preprocess \- Expand template text with embedded Perl .SH "VERSION" .IX Header "VERSION" version 1.55 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Text::Template::Preprocess; \& \& my $t = Text::Template::Preprocess\->new(...); # identical to Text::Template \& \& # Fill in template, but preprocess each code fragment with pp(). \& my $result = $t\->fill_in(..., PREPROCESSOR => \e&pp); \& \& my $old_pp = $t\->preprocessor(\e&new_pp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\f(CW\*(C`Text::Template::Preprocess\*(C'\fR provides a new \f(CW\*(C`PREPROCESSOR\*(C'\fR option to \&\f(CW\*(C`fill_in\*(C'\fR. If the \f(CW\*(C`PREPROCESSOR\*(C'\fR option is supplied, it must be a reference to a preprocessor subroutine. When filling out a template, \&\f(CW\*(C`Text::Template::Preprocessor\*(C'\fR will use this subroutine to preprocess the program fragment prior to evaluating the code. .PP The preprocessor subroutine will be called repeatedly, once for each program fragment. The program fragment will be in \f(CW$_\fR. The subroutine should modify the contents of \f(CW$_\fR and return. \&\f(CW\*(C`Text::Template::Preprocess\*(C'\fR will then execute contents of \f(CW$_\fR and insert the result into the appropriate part of the template. .PP \&\f(CW\*(C`Text::Template::Preprocess\*(C'\fR objects also support a utility method, \&\f(CW\*(C`preprocessor()\*(C'\fR, which sets a new preprocessor for the object. This preprocessor is used for all subsequent calls to \f(CW\*(C`fill_in\*(C'\fR except where overridden by an explicit \f(CW\*(C`PREPROCESSOR\*(C'\fR option. \&\f(CW\*(C`preprocessor()\*(C'\fR returns the previous default preprocessor function, or undefined if there wasn't one. When invoked with no arguments, \&\f(CW\*(C`preprocessor()\*(C'\fR returns the object's current default preprocessor function without changing it. .PP In all other respects, \f(CW\*(C`Text::Template::Preprocess\*(C'\fR is identical to \&\f(CW\*(C`Text::Template\*(C'\fR. .SH "WHY?" .IX Header "WHY?" One possible purpose: If your files contain a lot of JavaScript, like this: .PP .Vb 9 \& Plain text here... \& { perl code } \& \& { more perl code } \& More plain text... .Ve .PP You don't want \f(CW\*(C`Text::Template\*(C'\fR to confuse the curly braces in the JavaScript program with executable Perl code. One strategy: .PP .Vb 3 \& sub quote_scripts { \& s()(q{$1})gsi; \& } .Ve .PP Then use \f(CW\*(C`PREPROCESSOR => \e"e_scripts\*(C'\fR. This will transform .SH "SEE ALSO" .IX Header "SEE ALSO" Text::Template .SH "SOURCE" .IX Header "SOURCE" The development version is on github at and may be cloned from .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests on the bugtracker website .PP When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. .SH "AUTHOR" .IX Header "AUTHOR" Mark Jason Dominus, Plover Systems .PP Please send questions and other remarks about this software to \&\f(CW\*(C`mjd\-perl\-template+@plover.com\*(C'\fR .PP You can join a very low-volume (<10 messages per year) mailing list for announcements about this package. Send an empty note to \&\f(CW\*(C`mjd\-perl\-template\-request@plover.com\*(C'\fR to join. .PP For updates, visit \f(CW\*(C`http://www.plover.com/~mjd/perl/Template/\*(C'\fR. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2013 by Mark Jason Dominus . .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.