Templat...gin::CGI(3)
π Templat...gin::CGI(3) β the one and only
ok so bestie, this is a page from the User Contributed Perl Documentation and honestly? it's giving "small but mighty." it's the manual for Template::Plugin::CGI, and we're gonna go through it together, no cap π«Ά
πΈ NAME πΈ
Template::Plugin::CGI β a simple Template Toolkit plugin that interfaces to the CGI.pm module. that's it, that's the whole vibe. β¨
π VERSION π
version 3.101 β periodt, that's the version, don't @ me.
π¦ SYNOPSIS π¦
ok so here's the whole thing in action:
[% USE CGI %]
[% CGI.param('parameter') %]
[% USE things = CGI %]
[% things.param('name') %]
# see CGI docs for other methods provided by the CGI object
like, you literally just USE it and go. and bestie, that last line is important: see the CGI docs for other methods provided by the CGI object β this plugin isn't the whole menu, iykyk π
β DESCRIPTION β
okay so real talk: this is a very simple Template Toolkit Plugin interface to the CGI module. a CGI object gets instantiated via this directive right here:
[% USE CGI %]
and then CGI methods may be called like this:
[% CGI.header %]
[% CGI.param('parameter') %]
slay. now β you can also use an alias to give the object a different name to be identified by. iconic behaviour:
[% USE mycgi = CGI %]
[% mycgi.start_form %]
[% mycgi.popup_menu({ Name => 'Color'
Values => [ 'Green' 'Black' 'Brown' ] }) %]
and here's the β¨extraβ¨ part: parenthesised parameters to the USE directive get passed to the plugin constructor:
[% USE cgiprm = CGI('uid=abw&name=Andy+Wardley') %]
[% cgiprm.param('uid') %]
look at that. parameters going straight into the constructor. we love to see it π§
π NAME (again, yes really) π
so the page does the NAME thing a second time, and honestly? main character energy. it says:
Template::Plugin::CGI β Interface to the CGI module
short, sweet, to the point. π
π₯ METHODS π₯
so in addition to all the methods supported by the CGI module, this plugin defines the following. yes, in addition to. you're not losing anything, you're gaining π
π params() π
this one returns a reference to a hash of all the CGI parameters. and listen β any parameters that have multiple values will be returned as lists. so if a param shows up more than once, you get a whole list, not just one sad value. look:
[% USE CGI('user=abw&item=foo&item=bar') %]
[% CGI.params.user %] # abw
[% CGI.params.item.join(', ') %] # foo, bar
see how user is just abw but item has two entries? yeah. join(', ') ate that. π₯
π«Ά AUTHOR π«Ά
Andy Wardley <abw@wardley.org> <http://wardley.org/>
(go follow the link bestie, it's literally right there π)
π COPYRIGHT π
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
and then the licensing bit, which is important so pay attention:
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
that's the whole deal. free software, same terms as Perl itself, no funny business. πΈ
π SEE ALSO π
Template::PluginCGI
go read those too, they're literally the siblings of this page. iykyk π¦
β AUTHOR (yes, a second one) β
Andy Wardley β again. the man is consistent. π
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2022 by Andy Wardley.
and it's free software, licensed under:
The MIT (X11) License
that's the license, no cap. read it if you're gonna redistribute, bestie. π
okay and the last thing, the little footer crumbs: this page was generated for perl v5.40.0 and dated 2024-07-19, brought to you by the lovely humans doing the Perl docs thing. go forth and USE CGI responsibly, mwah πβ¨π
π¦ where this page comes from
- epel 10: perl-Template-Plugin-CGI 3.101-8.el10_0 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms