Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

template::stash::context(3) [suse man page]

Template::Stash::Context(3)				User Contributed Perl Documentation			       Template::Stash::Context(3)

NAME
Template::Stash::Context - Experimetal stash allowing list/scalar context definition SYNOPSIS
use Template; use Template::Stash::Context; my $stash = Template::Stash::Context->new(\%vars); my $tt2 = Template->new({ STASH => $stash }); DESCRIPTION
This is an alternate stash object which includes a patch from Craig Barratt to implement various new virtual methods to allow dotted template variable to denote if object methods and subroutines should be called in scalar or list context. It adds a little overhead to each stash call and I'm a little wary of applying that to the core default stash without investigating the effects first. So for now, it's implemented as a separate stash module which will allow us to test it out, benchmark it and switch it in or out as we require. This is what Craig has to say about it: Here's a better set of features for the core. Attached is a new version of Stash.pm (based on TT2.02) that: * supports the special op "scalar" that forces scalar context on function calls, eg: cgi.param("foo").scalar calls cgi.param("foo") in scalar context (unlike my wimpy scalar op from last night). Array context is the default. With non-function operands, scalar behaves like the perl version (eg: no-op for scalar, size for arrays, etc). * supports the special op "ref" that behaves like the perl ref. If applied to a function the function is not called. Eg: cgi.param("foo").ref does *not* call cgi.param and evaluates to "CODE". Similarly, HASH.ref, ARRAY.ref return what you expect. * adds a new scalar and list op called "array" that is a no-op for arrays and promotes scalars to one-element arrays. * allows scalar ops to be applied to arrays and hashes in place, eg: ARRAY.repeat(3) repeats each element in place. * allows list ops to be applied to scalars by promoting the scalars to one-element arrays (like an implicit "array"). So you can do things like SCALAR.size, SCALAR.join and get a useful result. This also means you can now use x.0 to safely get the first element whether x is an array or scalar. The new Stash.pm passes the TT2.02 test suite. But I haven't tested the new features very much. One nagging implementation problem is that the "scalar" and "ref" ops have higher precedence than user variable names. AUTHOR
Andy Wardley <abw@wardley.org> <http://wardley.org/> VERSION
1.63, distributed as part of the Template Toolkit version 2.19, released on 27 April 2007. COPYRIGHT
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Stash perl v5.12.1 2009-04-07 Template::Stash::Context(3)

Check Out this Related Man Page

Template::Config(3)					User Contributed Perl Documentation				       Template::Config(3)

NAME
Template::Config - Factory module for instantiating other TT2 modules SYNOPSIS
use Template::Config; DESCRIPTION
This module implements various methods for loading and instantiating other modules that comprise the Template Toolkit. It provides a consistent way to create toolkit components and allows custom modules to be used in place of the regular ones. Package variables such as $STASH, $SERVICE, $CONTEXT, etc., contain the default module/package name for each component (Template::Stash, Template::Service and Template::Context, respectively) and are used by the various factory methods (stash(), service() and context()) to load the appropriate module. Changing these package variables will cause subsequent calls to the relevant factory method to load and instantiate an object from the new class. PUBLIC METHODS
load($module) Load a module using Perl's require(). Any occurences of '"::"' in the module name are be converted to '"/"', and '".pm"' is appended. Returns 1 on success or undef on error. Use "$class->error()" to examine the error string. preload() This method preloads all the other "Template::*" modules that are likely to be used. It is called automatically by the Template module when running under mod_perl ($ENV{MOD_PERL} is set). parser(\%config) Instantiate a new parser object of the class whose name is denoted by the package variable $PARSER (default: Template::Parser). Returns a reference to a newly instantiated parser object or undef on error. provider(\%config) Instantiate a new template provider object (default: Template::Provider). Returns an object reference or undef on error, as above. plugins(\%config) Instantiate a new plugins provider object (default: Template::Plugins). Returns an object reference or undef on error, as above. filters(\%config) Instantiate a new filter provider object (default: Template::Filters). Returns an object reference or undef on error, as above. stash(\%vars) Instantiate a new stash object (Template::Stash or Template::Stash::XS depending on the default set at installation time) using the contents of the optional hash array passed by parameter as initial variable definitions. Returns an object reference or undef on error, as above. context(\%config) Instantiate a new template context object (default: Template::Context). Returns an object reference or undef on error, as above. service(\%config) Instantiate a new template service object (default: Template::Service). Returns an object reference or undef on error, as above. iterator(\%config) Instantiate a new template iterator object (default: Template::Iterator). Returns an object reference or undef on error, as above. constants(\%config) Instantiate a new namespace handler for compile time constant folding (default: Template::Namespace::Constants). Returns an object reference or undef on error, as above. instdir($dir) Returns the root directory of the Template Toolkit installation under which optional components are installed. Any relative directory specified as an argument will be appended to the returned directory. # e.g. returns '/usr/local/tt2' my $ttroot = Template::Config->instdir() || die "$Template::Config::ERROR "; # e.g. returns '/usr/local/tt2/templates' my $template = Template::Config->instdir('templates') || die "$Template::Config::ERROR "; Returns "undef" and sets $Template::Config::ERROR appropriately if the optional components of the Template Toolkit have not been installed. AUTHOR
Andy Wardley <abw@wardley.org> <http://wardley.org/> COPYRIGHT
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template perl v5.12.1 2010-07-05 Template::Config(3)
Man Page