Templa...SIColor(3pm)

πŸ“¦ version 0.0.3, in opensuse-leap 16.0

πŸ’– 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 nocolor option is on
  • Term::Terminfo says 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 πŸ‘‘

  • Template
  • Term::ANSIColor
  • Term::Terminfo
  • Template::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/>


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