The following module was proposed for inclusion in the Module List:
modid: Template::Plugin::EnvHash
DSLIP: RdpOp
description: Environment Variable Hash for TT2
userid: SRSHAH (Sagar R. Shah)
chapterid: 11 (String_Lang_Text_Proc)
communities:
none - trivial (but very useful imho) module.
similar:
no similar Template Toolkit plugins known. Env has a similar name
for standard perl, but does something quite different.
rationale:
NAME Template::Plugin::EnvHash - Environment Variable Hash for TT2
SYNOPSIS [% USE env = EnvHash %] [% env.SOME_ENV_VAR %]
DESCRIPTION This is a trivial Template::Toolkit plugin to allow any
template writer to suck environment variables into their template. I
wrote it because i was sick of passing %ENV as one of the contents
of the vars hash that i pass to the process method of Template.
NAMING I've named this module EnvHash rather than Env because most
Template::Plugin::X modules are wrappers around module X. Whereas
this is *not* a wrapper around Perl's Env module. This is because
the purpose of that module is to export environment variables into a
package. I did not want to export environment variables into my
template as environment variables as most environment variables tend
to have capitalised names (by popular convention) and this might
cause confusion with the tt2 style of using capitalised words for
its control structure syntax.
Of course someone else might come along and not care about this, so
i leave Template::Plugin::Env free for such a person.
USING ENVIRONMENT VARIABLES IN TEMPLATES As well as this being a
useful module for sucking in standard environment variables it also
allows you to configure template via the environment.
Some might say using the environment variables to configure your
template is dangerous, and in an *uncontrolled environment* i would
agree. However if you have a *controlled* environment it can be
incredibly useful. Say for example you quickly want to fire your
usual apache server, but on a different port (perhaps because u want
to test two sets of changes simultaneous, or perhaps just because
someone else is using that port). Then using an environment variable
to pass the port number can be quick dirty and useful.
Config files are generally better in the long run for most things,
but as i say it can be useful in a *controlled* environment.
INSTALLATION This module uses Module::Build for its installation.
To install this module type the following:
perl Build.PL ./Build ./Build test ./Build install
If you do not have Module::Build type:
perl Makefile.PL
to fetch it. Or use CPAN or CPANPLUS and fetch it "manually".
BUGS None known at time of writing. To report a bug or request an
enhancement use CPAN's excellent Request Tracker:
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Template-Plugin-EnvHash>
AUTHOR Sagar R. Shah
COPYRIGHT Copyright 2003, Sagar R. Shah, All rights reserved
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file
included with this module.
enteredby: SRSHAH (Sagar R. Shah)
enteredon: Sun Sep 14 10:46:42 2003 GMT
The resulting entry would be:
Template::Plugin::
::EnvHash RdpOp Environment Variable Hash for TT2 SRSHAH
Thanks for registering,
--
The PAUSE
PS: The following links are only valid for module list maintainers:
Registration form with editing capabilities:
https://pause.perl.org/pause/authenquery?ACTION=add_mod&USERID=0c400000_68286917354f230d&SUBMIT_pause99_add_mod_preview=1
Immediate (one click) registration:
https://pause.perl.org/pause/authenquery?ACTION=add_mod&USERID=0c400000_68286917354f230d&SUBMIT_pause99_add_mod_insertit=1