Name

values-space — switch between value namespaces

ATTRIBUTES

Attribute Pos. Req. Default Description
name Yes   Switch namespace. Empty value (name="") switches back to the main namespace.
copy-all     0 Copy all values from the current namespace to the new one before switching to it? (dereference on nested data structures is not performed).
copy       Copy only specified, space-separated values.
clear     0 Clear all values in the target namespace before switching to it?
show     0 Return name of the current namespace, then switch to a new one?
interpolate     0 interpolate output?
hide     0 Hide the tag return value?

DESCRIPTION

This tag switches the values namespace for the duration of the page. To switch back to the default namespace, use [values-space name=''].

The current namespace is kept in the $Vend::ValuesSpace variable.

BEHAVIOR

This tag does not appear to be affected by, or affect, the rest of Interchange.

EXAMPLES

Example: Switch and display namespaces

Current namespace is: [values-space] 
Switching to namespace 'basket': [values-space basket]
Switching [values-space name=checkout show=1 clear=1] to clear [values-space]

NOTES

AVAILABILITY

values-space is available in Interchange versions:

4.6.0-5.9.0 (git-head)

SOURCE

Interchange 5.9.0:

Source: code/UserTag/values_space.tag
Lines: 49


# Copyright 2004-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: values_space.tag,v 1.5 2007-03-30 23:40:57 pajamian Exp $

UserTag values-space Order   name
UserTag values-space addAttr
UserTag values-space Version $Revision: 1.5 $
UserTag values-space Routine <<EOR
sub {
my ($name, $opt) = @_;
return $Vend::ValuesSpace unless defined $name;

my $old_name = $Vend::ValuesSpace;
my $old_ref;
if ($old_name eq '') {
  $old_ref = $Vend::Session->{values};
}
else {
  $old_ref = $Vend::Session->{values_repository}{$old_name} ||= {};
}

if ($name eq '') {
  $::Values = $Vend::Session->{values};
}
else {
  $::Values = $Vend::Session->{values_repository}{$name} ||= {};
}
$Vend::ValuesSpace = $name;

%$::Values = () if $opt->{clear};

my @copy;
if ($opt->{copy_all}) {
  @copy = keys %$old_ref;
}
elsif ($opt->{copy}) {
  @copy = grep /\S/, split / /, $opt->{copy};
}
$::Values->{$_} = $old_ref->{$_} for @copy;

#Debug("changed values space from $old_name to $name; new contents:\n" . ::uneval($::Values));
return $opt->{show} ? $old_name : '';
}
EOR

AUTHORS

Interchange Development Group

SEE ALSO

value(7ic), value-extended(7ic)

DocBook! Interchange!