Text::T...process(3)
π NAME π
Okay bestie, welcome to the Text::T...process(3) manual page π β this whole thing is about Text::Template::Preprocess, and its whole vibe is: Expand template text with embedded Perl. That's the name and the one-liner, and it ate. β¨
β¨ VERSION β¨
This is version 1.61, periodt. π
π¦ SYNOPSIS π¦
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 => \&pp);
my $old_pp = $t->preprocessor(\&new_pp);
πΈ DESCRIPTION πΈ
Text::Template::Preprocess provides a new PREPROCESSOR option to fill_in. If the PREPROCESSOR option is supplied, it must be a reference to a preprocessor subroutine. When filling out a template, Text::Template::Preprocessor will use this subroutine to preprocess the program fragment prior to evaluating the code. (Yes bestie, that's the name as printed in this sentence β Preprocessor β we're preserving the lore. π)
The preprocessor subroutine will be called repeatedly, once for each program fragment. The program fragment will be in $_. The subroutine should modify the contents of $_ and return. Text::Template::Preprocess will then execute contents of $_ and insert the result into the appropriate part of the template. Slay. π
Text::Template::Preprocess objects also support a utility method, preprocessor(), which sets a new preprocessor for the object. This preprocessor is used for all subsequent calls to fill_in except where overridden by an explicit PREPROCESSOR option. preprocessor() returns the previous default preprocessor function, or undefined if there wasn't one. When invoked with no arguments, preprocessor() returns the object's current default preprocessor function without changing it.
In all other respects, Text::Template::Preprocess is identical to Text::Template. No cap. π«Ά
π₯ WHY? π₯
One possible purpose: If your files contain a lot of JavaScript, like this:
Plain text here...
{ perl code }
<script language=JavaScript>
if (br== "n3") {
// etc.
}
</script>
{ more perl code }
More plain text...
You don't want Text::Template to confuse the curly braces in the JavaScript program with executable Perl code. One strategy:
sub quote_scripts {
s(<script(.*?)</script>)(q{$1})gsi;
}
Then use PREPROCESSOR => \"e_scripts. This will transform
And that's where the original stops. Literally This will transform and then vibes. π We are not adding words to it, bestie β that's the whole line.
π SEE ALSO π
Text::Templateβ that's it. Go read it, bestie. π
π SOURCE π
The development version is on github at <https://https://github.com/mschout/perl-text-template> and may be cloned from <git://https://github.com/mschout/perl-text-template.git>.
π BUGS π
Please report any bugs or feature requests on the bugtracker website <https://github.com/mschout/perl-text-template/issues>.
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. Fr fr, include the test-file. π«Ά
π AUTHOR π
Mark Jason Dominus, Plover Systems
Please send questions and other remarks about this software to mjd-perl-template+@plover.com.
You can join a very low-volume (<10 messages per year) mailing list for announcements about this package. Send an empty note to mjd-perl-template-request@plover.com to join.
For updates, visit http://www.plover.com/~mjd/perl/Template/.
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2013 by Mark Jason Dominus <mjd@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Bye bestie π«Ά this page is from perl v5.42.0, dated 2022-04-29, and yes it's the Text::T...process(3) manual. Slay and hydrate. π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Text-Template 1.61-bp160.1.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms