1Template::Stash::ContexUts(e3r)Contributed Perl DocumentTaetmipolnate::Stash::Context(3)
2
3
4

NAME

6       Template::Stash::Context - Experimetal stash allowing list/scalar
7       context definition
8

SYNOPSIS

10           use Template;
11           use Template::Stash::Context;
12
13           my $stash = Template::Stash::Context->new(\%vars);
14           my $tt2   = Template->new({ STASH => $stash });
15

DESCRIPTION

17       This is an alternate stash object which includes a patch from Craig
18       Barratt to implement various new virtual methods to allow dotted
19       template variable to denote if object methods and subroutines should be
20       called in scalar or list context.  It adds a little overhead to each
21       stash call and I'm a little wary of applying that to the core default
22       stash without investigating the effects first. So for now, it's
23       implemented as a separate stash module which will allow us to test it
24       out, benchmark it and switch it in or out as we require.
25
26       This is what Craig has to say about it:
27
28       Here's a better set of features for the core.  Attached is a new
29       version of Stash.pm (based on TT2.02) that:
30
31       * supports the special op "scalar" that forces scalar context on
32       function calls, eg:
33
34           cgi.param("foo").scalar
35
36       calls cgi.param("foo") in scalar context (unlike my wimpy scalar op
37       from last night).  Array context is the default.
38
39       With non-function operands, scalar behaves like the perl version (eg:
40       no-op for scalar, size for arrays, etc).
41
42       * supports the special op "ref" that behaves like the perl ref.  If
43       applied to a function the function is not called.  Eg:
44
45           cgi.param("foo").ref
46
47       does *not* call cgi.param and evaluates to "CODE".  Similarly,
48       HASH.ref, ARRAY.ref return what you expect.
49
50       * adds a new scalar and list op called "array" that is a no-op for
51       arrays and promotes scalars to one-element arrays.
52
53       * allows scalar ops to be applied to arrays and hashes in place, eg:
54       ARRAY.repeat(3) repeats each element in place.
55
56       * allows list ops to be applied to scalars by promoting the scalars to
57       one-element arrays (like an implicit "array").  So you can do things
58       like SCALAR.size, SCALAR.join and get a useful result.
59
60       This also means you can now use x.0 to safely get the first element
61       whether x is an array or scalar.
62
63       The new Stash.pm passes the TT2.02 test suite.  But I haven't tested
64       the new features very much.  One nagging implementation problem is that
65       the "scalar" and "ref" ops have higher precedence than user variable
66       names.
67

AUTHOR

69       Andy Wardley <abw@wardley.org>
70
71       <http://wardley.org/>
72

VERSION

74       1.63, distributed as part of the Template Toolkit version 2.19,
75       released on 27 April 2007.
76
78         Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.
79
80       This module is free software; you can redistribute it and/or modify it
81       under the same terms as Perl itself.
82

SEE ALSO

84       Template::Stash
85
86
87
88perl v5.12.0                      2009-04-07       Template::Stash::Context(3)
Impressum