<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>GT::Template::Vars - Tied hash for template tags handling</title> <link rev="made" href="mailto:root@penguin.office.gossamer-threads.com" /> <style type="text/css"> /* $MVD$:fontset("Untitled Font Set 1","ARIEL","HELVETICA","HELV","SANSERIF") */ /* $MVD$:fontset("Arial","Arial") */ /* $MVD$:fontset("Arial Black","Arial Black") */ /* $MVD$:fontset("Algerian","Algerian") */ body { background-color: white; font-family: Verdana, Arial, sans-serif; font-size: small; color: black; } p { background-color : white; font-family : Verdana, Arial, sans-serif; font-size : small; color : black; } h1 { font-family : Verdana, Arial, sans-serif; font-weight : bold; font-size : medium; background-color : white; color : maroon; } h2 { font-family : Verdana, Arial, sans-serif; font-size : medium; font-weight : bold; color : blue; background-color : white; } h3 { font-family : Verdana, Arial, sans-serif; font-weight : bold; font-size : medium; color : black; background-color : white; } h4 { font-family : Verdana, Arial, sans-serif; font-weight : bold; font-size : small; color : maroon; background-color : white; } h5 { font-family : Verdana, Arial, sans-serif; font-weight : bold; font-size : small; color : blue; background-color : white; } h6 { font-family : Verdana, Arial, sans-serif; font-weight : bold; font-size : small; color : black; background-color : white; } ul { font-family : Verdana, Arial, sans-serif; font-size : small; color : black; } ol { font-family : Verdana, Arial, sans-serif; font-size : small; color : black; } dl { font-family : Verdana, Arial, sans-serif; font-size : small; color : black; } li { font-family : Verdana, Arial, sans-serif; font-size : small; color : black; } th { font-family : Verdana, Arial, sans-serif; font-size : small; color : black; } td { font-family : Verdana, Arial, sans-serif; font-size : small; color : black; } dl { font-family : Verdana, Arial, sans-serif; font-size : small; color : black; } dd { font-family : Verdana, Arial, sans-serif; font-size : small; color : black; } dt { font-family : Verdana, Arial, sans-serif; font-size : small; color : black; } code { font-family : Courier; font-size : small; color : black; } pre { font-family : Courier; font-size : small; color : black; } .mvd-H1 { font-family : Verdana, Arial, sans-serif; font-weight : bold; font-size : 14.0pt; background-color : transparent; background-image : none; color : maroon; } .mvd-H2 { font-family : Verdana, Arial, sans-serif; font-size : 12.0pt; color : blue; } p.indent { font-family : "Verdana, Arial, sans-serif"; list-style-type : circle; list-style-position : inside; color : black; margin-left : 16.0pt; } .mvd-P-indent { font-family : Verdana, Arial, sans-serif; list-style-type : circle; list-style-position : inside; color : black; margin-left : 16.0pt; } pre.programlisting { font-size : 9.0pt; list-style-type : disc; margin-left : 16.0pt; margin-top : -14.0pt; } .mvd-PRE-programlisting { font-size : 9.0pt; list-style-type : disc; margin-left : 16.0pt; margin-top : -14.0pt; } .mvd-PRE { font-size : 9.0pt; } p.note { margin-left : 28.0pt; } .mvd-P-note { margin-left : 28.0pt; } .mvd-H4 { font-family : Verdana, Arial, sans-serif; font-weight : normal; font-size : 9.0pt; color : black; margin-left : 6.0pt; margin-top : -14.0pt; } .mvd-P { font-family : Verdana, Arial, sans-serif; font-size : 10.0pt; color : black; } .mvd-BODY { font-family : Verdana, Arial, sans-serif; background-color : white; } p.indentnobullet { font-family : Verdana, Arial, sans-serif; list-style-type : none; } .mvd-P-indentnobullet { font-family : Verdana, Arial, sans-serif; list-style-type : none; } </style> </head> <body style="background-color: white"> <p><a name="__index__"></a></p> <!-- INDEX BEGIN --> <ul> <li><a href="#name">NAME</a></li> <li><a href="#synopsis">SYNOPSIS</a></li> <li><a href="#description">DESCRIPTION</a></li> <li><a href="#interface">INTERFACE</a></li> <ul> <li><a href="#accessing_values">Accessing values</a></li> <li><a href="#setting_values">Setting values</a></li> <li><a href="#keys__exists">Keys, Exists</a></li> </ul> <li><a href="#see_also">SEE ALSO</a></li> <li><a href="#maintainer">MAINTAINER</a></li> <li><a href="#copyright">COPYRIGHT</a></li> <li><a href="#version">VERSION</a></li> </ul> <!-- INDEX END --> <hr /> <p> </p> <h1><a name="name">NAME</a></h1> <p>GT::Template::Vars - Tied hash for template tags handling</p> <p> </p> <hr /> <h1><a name="synopsis">SYNOPSIS</a></h1> <pre> my $vars = GT::Template->vars; print $vars->{foo};</pre> <p> </p> <hr /> <h1><a name="description">DESCRIPTION</a></h1> <p>This module is designed to provide a simple interface to GT::Template tags from Perl code. Prior to this module, the <code>tags()</code> 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.</p> <p> </p> <hr /> <h1><a name="interface">INTERFACE</a></h1> <p> </p> <h2><a name="accessing_values">Accessing values</a></h2> <p>Accessing a value is simple - just access <code>$vars->{name}</code>. 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.</p> <p> </p> <h2><a name="setting_values">Setting values</a></h2> <p>Setting a value is easy - simply do: <code>$vars->{name} = $value;</code>. ``name'' can be anything GT::Template recognises as a variable, so <code>$vars->{'name.key'}</code> would set <code>->{name}->{key}</code> (see <a href="glist.cgi?do=admin_gtdoc&topic=/GT/Template/Tutorial.html#advanced_variables_using_references">Advanced variables using references in the GT::Template::Tutorial manpage</a> for more information on complex variables).</p> <p>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: <code>$vars->{name} = \$value;</code>.</p> <p> </p> <h2><a name="keys__exists">Keys, Exists</a></h2> <p>You can use <code>keys %$vars</code> to get a list of keys of the tag object, but you should note that while <code>$vars->{"a.b"}</code> is valid and <code>exists $vars->{"a.b"}</code> may return true, it will <strong>not</strong> be present in the list of keys returned by <code>keys %$vars</code>.</p> <p> </p> <hr /> <h1><a name="see_also">SEE ALSO</a></h1> <p><a href="glist.cgi?do=admin_gtdoc&topic=/GT/Template.html">the GT::Template manpage</a></p> <p><a href="glist.cgi?do=admin_gtdoc&topic=/GT/Template/Tutorial.html">the GT::Template::Tutorial manpage</a></p> <p> </p> <hr /> <h1><a name="maintainer">MAINTAINER</a></h1> <p>Jason Rhinelander</p> <p> </p> <hr /> <h1><a name="copyright">COPYRIGHT</a></h1> <p>Copyright (c) 2005 Gossamer Threads Inc. All Rights Reserved. <a href="http://www.gossamer-threads.com/">http://www.gossamer-threads.com/</a></p> <p> </p> <hr /> <h1><a name="version">VERSION</a></h1> <p>Revision: $Id: Vars.pm,v 1.3 2005/03/05 01:17:20 jagerman Exp $</p> </body> </html>