- NAME
- SYNOPSIS
- DESCRIPTION
- INTERFACE

- Accessing values
- Setting values
- Keys, Exists

- SEE ALSO
- MAINTAINER
- COPYRIGHT
- VERSION

# NAME

GT::Template::Vars - Tied hash for template tags handling

# SYNOPSIS

        my $vars = GT::Template->vars;
        print $vars->{foo};

# DESCRIPTION

This module is designed to provide a simple interface to GT::Template tags from Perl code. Prior to this module, the `tags()` method of GT::Template returned a hash reference which could contain all sorts of different values - scalar references, LVALUE references, GT::Config objects, etc. This new interface provides a tied hash reference designed to aid in retrieving and setting values in the same way template variables are retrieved and set from templates.

# INTERFACE

## Accessing values

Accessing a value is simple - just access `$vars->{name}`. The regular rules of escaping apply here: if the value would have been HTML-escaped in the template, it will be escaped when you get it.

## Setting values

Setting a value is easy - simply do: `$vars->{name} = $value;`. ``name'' can be anything GT::Template recognises as a variable, so `$vars->{'name.key'}` would set `->{name}->{key}` (see Advanced variables using references in the GT::Template::Tutorial manpage for more information on complex variables).

The regular rules of escaping apply here: if escaping is turned on, a value you set will be escaped when accessed again via $vars or in a template. If you want to set a tag containing raw HTML, you should set a scalar reference, such as: `$vars->{name} = \$value;`.

## Keys, Exists

You can use `keys %$vars` to get a list of keys of the tag object, but you should note that while `$vars->{"a.b"}` is valid and `exists $vars->{"a.b"}` may return true, it will not be present in the list of keys returned by `keys %$vars`.

# SEE ALSO

the GT::Template manpage

the GT::Template::Tutorial manpage

# MAINTAINER

Jason Rhinelander

# COPYRIGHT

Copyright (c) 2005 Gossamer Threads Inc. All Rights Reserved. http://www.gossamer-threads.com/

# VERSION

Revision: $Id: Vars.pm,v 1.8 2006/12/06 23:55:52 brewt Exp $