cgi — get or set value of CGI input variables
| Attribute | Pos. | Req. | Default | Description |
|---|---|---|---|---|
| name | Yes | Yes | Name of the CGI input variable. | |
| set | None. | New value for a variable to set, instead of retrieving the current content. | ||
| default | None. | Text to return if the variable requested is missing or otherwise false. | ||
| enable_html | 0 | Allow HTML tags to appear in the output? By default, All < characters are replaced by <. | ||
| keep | 0 |
Do apply filter for display, but do not modify the original
CGI value itself (from the the $CGI::values hash)?
|
||
| filter | None. | filter to apply. | ||
| interpolate | 0 | interpolate output? | ||
| hide | 0 | Hide the tag return value? |
The tag displays the value of a CGI variable submitted to a current page.
This is similar to the [value] tag, except that it displays
transitory values that have been submitted with the current request.
In other words, the CGI values are reset on each request and you can
only access the values directly submitted to the current page.
For instance, if you invoke the page with GET
parameters, such as pagename?foo=bar,
then the value of the foo CGI variable will be
accessible using [cgi foo] in
ITL or $CGI->{foo} in embedded Perl.
Example: Accessing CGI variables
Save the following content to a test page named say,
cgitest.html, then visit
cgitest?foo=bar&toad=stool with your browser.
Value of 'foo': [cgi foo]<br/> Value of 'toad': [cgi name=toad]<br/>
Interchange 5.7.0:
Source: code/SystemTag/cgi.coretag
Lines: 37
# Copyright 2002-2007 Interchange Development Group and others
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. See the LICENSE file for details.
#
# $Id: cgi.coretag,v 1.6 2007/03/30 23:40:49 pajamian Exp $
UserTag cgi Order name
UserTag cgi addAttr
UserTag cgi PosNumber 1
UserTag cgi Version $Revision: 1.6 $
UserTag cgi Routine <<EOR
sub {
my($var, $opt) = @_;
my($value);
local($^W) = 0;
$CGI::values{$var} = $opt->{set} if defined $opt->{set};
$value = defined $CGI::values{$var} ? ($CGI::values{$var}) : '';
if ($value) {
# Eliminate any Interchange tags
$value =~ s~<([A-Za-z]*[^>]*\s+[Mm][Vv]\s*=\s*)~<$1~g;
$value =~ s/\[/[/g;
}
if($opt->{filter}) {
$value = filter_value($opt->{filter}, $value, $var);
$CGI::values{$var} = $value unless $opt->{keep};
}
return '' if $opt->{hide};
$value =~ s/</</g unless $opt->{enable_html};
return $value;
}
EOR