Templa...SIColor(3pm)
π NAME π
Template::Plugin::Filter::ANSIColor β bestie, it literally colorizes your text using ANSI colors β¨ (yes, that's the whole vibe, and it ate)
This page lives in the perl section 3pm of the manual, mmmkay? π«Ά
π VERSION π
Version 0.03 β lil baby version number, but she's iconic π
π SYNOPSIS π
Okay so listen: this is a Template Toolkit filter that colors your text using Term::ANSIColor. It works on terminals that support at least 8 colors β anything less and she's not showing up to the party, no cap π
use Template;
my $engine = Template->new(
PLUGIN_BASE => 'Template::Plugin::Filter'
) || die Template->error();
$engine->process(\*DATA)
|| die $engine->error();
__DATA__
[% USE ANSIColor 'color' %]
[% "this is red on bright yellow " | color 'red' 'on_bright_yellow' %]
[% "this is simply green " | color 'green' %]
[% "this is default on bright magenta" | color 'on_bright_magenta' %]
[% "this is default on deault since nocolor=1" | color 'red' nocolor = 1 %]
(yes, deault is a typo up there in the original example β we're keeping it exactly as-is because that's literally what's in the docs π)
β¨ METHODS β¨
πΈ init
So this method gets invoked when Template Toolkit spots a directive like [% USE ANSIColor 'color' %]. The argument 'color' is the name for the filter β you can totally change it if you need, it's not that deep πββοΈ
It has an option called nocolor, which turns off colors (aka the filter just⦠won't modify the text, she'll simply vibe and do nothing). Probably you'd wanna use it like this:
# .....
$engine->process(\*DATA, { colors_off => 1 })
|| die $engine->error();
__DATA__
[% USE ANSIColor 'color' nocolor = colors_off %]
...
See 'TO COLOR OR NOT TO COLOR' below π
π¦ filter
This is the filter itself, main character energy, the whole point π It returns colored text if colors are not turned off. It accepts one or two parameters β the foreground and/or background color names. You may also use the nocolor option. See SYNOPSIS above. See TO COLOR OR NOT TO COLOR.
π TO COLOR OR NOT TO COLOR π
Text is not modified if:
- the
nocoloroption is on Term::Terminfosays that the maximum number of colors supported by the current terminal is less than 8 or undefined
Lowkey that second one is the vibe check for your terminal π like if your terminal can't serve 8 colors, no colors for you bestie.
π SEE ALSO π
TemplateTerm::ANSIColorTerm::TerminfoTemplate::Plugin::Filter
π AUTHOR π
"Andrei V. Toutoukine", "<"tut at isuct.ru">" β that's literally how it's written in the original, angle brackets inside quotes and everything, we don't edit quotes around here π
π BUGS π
Please report any bugs or feature requests to "bug-template-plugin-filter-ansicolor at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Template-Plugin-Filter-ANSIColor>.
The author will be notified, and then you'll automatically be notified of progress on your bug as changes get made π«Ά (a whole lil notification pipeline, obsessed)
π SUPPORT π
You can find documentation for this module with the perldoc command:
perldoc Template::Plugin::Filter::ANSIColor
You can also look for information at:
- RT: CPAN's request tracker
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Template-Plugin-Filter-ANSIColor>
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/Template-Plugin-Filter-ANSIColor>
- CPAN Ratings
<http://cpanratings.perl.org/d/Template-Plugin-Filter-ANSIColor>
- Search CPAN
<http://search.cpan.org/dist/Template-Plugin-Filter-ANSIColor/>
β LICENSE AND COPYRIGHT β
Copyright 2011 "Andrei V. Toutoukine".
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See <http://dev.perl.org/licenses/> for more information.
fr fr read the license before you redistribute, it's giving "respect the author" energy π
and that's the whole page, bestie π§π generated by perl v5.42.0, dated 2020-11-24 β go forth and colorize responsibly, iykyk πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Template-Plugin-Filter-ANSIColor 0.0.3-bp160.1.10 Β· 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