Variable — define an Interchange variable
The directive defines a variable that will be available either
globally (if defined in interchange.cfg
) or within a catalog (if defined in catalog.cfg
).
Variable names are case sensitive and can only contain word characters (that is, a-z, A-Z, 0-9 and _).
Once the variable is defined, it can be accessed using the following syntax:
__
- to only look for a catalog variable
NAME
__
@@
- to only look for a global variable
NAME
@@
@_
- to first look for a catalog variable, falling back to global
unless found
NAME
_@
Using the [var]
tag (Note: the [var]
tag is parsed together with
all other tags, unlike the previous methods which are parsed separately,
before ITL tag processing takes place)
Variable names do not need to begin with a capital letter (unlike the documentation prior to Interchange 5.4 release stated), even though specifying them in all-uppercase is a widely accepted practice.
Interchange 5.9.0:
Source: lib/Vend/Config.pm
Line 5295 (context shows lines 5295-5317)
sub parse_variable { my ($var, $value) = @_; my ($c, $name, $param); # Allow certain catalogs global subs unless (defined $value and $value) { $c = { 'save' => {} }; return $c; } if(defined $C) { $c = $C->{$var}; } else { no strict 'refs'; $c = ${"Global::$var"}; } ($name, $param) = split /\s+/, $value, 2; chomp $param; $c->{$name} = $param; return $c; }