1Template::Namespace::CoUnssetranCtosn(t3r)ibuted Perl DoTceummpelnattaet:i:oNnamespace::Constants(3)
2
3
4

NAME

6       Template::Namespace::Constants - Compile time constant folding
7

SYNOPSIS

9           # easy way to define constants
10           use Template;
11
12           my $tt = Template->new({
13               CONSTANTS => {
14                   pi => 3.14,
15                   e  => 2.718,
16               },
17           });
18
19           # nitty-gritty, hands-dirty way
20           use Template::Namespace::Constants;
21
22           my $tt = Template->new({
23               NAMESPACE => {
24                   constants => Template::Namespace::Constants->new({
25                       pi => 3.14,
26                       e  => 2.718,
27                   },
28               },
29           });
30

DESCRIPTION

32       The "Template::Namespace::Constants" module implements a namespace
33       handler which is plugged into the "Template::Directive" compiler
34       module.  This then performs compile time constant folding of variables
35       in a particular namespace.
36

METHODS

38   new(\%constants)
39       The new() constructor method creates and returns a reference to a new
40       Template::Namespace::Constants object.  This creates an internal stash
41       to store the constant variable definitions passed as arguments.
42
43           my $handler = Template::Namespace::Constants->new({
44               pi => 3.14,
45               e  => 2.718,
46           });
47
48   ident(\@ident)
49       Method called to resolve a variable identifier into a compiled form.
50       In this case, the method fetches the corresponding constant value from
51       its internal stash and returns it.
52

AUTHOR

54       Andy Wardley <abw@wardley.org> <http://wardley.org/>
55
57       Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.
58
59       This module is free software; you can redistribute it and/or modify it
60       under the same terms as Perl itself.
61

SEE ALSO

63       Template::Directive
64
65
66
67perl v5.28.1                      2018-10-05 Template::Namespace::Constants(3)
Impressum