[LA.pm] What to call a small module
Uri Guttman
uri at stemsystems.com
Mon Apr 30 20:54:06 PDT 2012
On 04/30/2012 09:47 PM, Ben Tilly wrote:
> I have a small module, I just don't know what to call it. Does anyone
> have any suggestions?
>
> It just takes a hash, and expands it as a template, with the variables
> referring to other keys. It can even handle nested hashes. So you
> might pass it something like this:
>
> {
> user => 'btilly',
> project_root => '/home/[% user %]/foo',
> template_root => '[% project_root %]/app/view',
> escaped => '\[% watch_this %]',
> }
>
> and then get back:
>
> {
> user => 'btilly',
> project_root => '/home/btilly/foo',
> template_root => '/home/btilly/foo//app/view',
> escaped => '[% watch_this %]',
> }
>
> The use case is mostly for configuration files, where you'd have a
> hash describing a basic sandbox template, override the values you need
> to, and then get the configuration for a developer. With this sort of
> templating, the amount that you need to override goes way down.
couple of ideas:
Template::HashValues
Template::Config
but why another template module? template::simple can do that with a
simple values loop (untested):
# add template paths or files here
my $tmpl = Template::Simple->new() ;
# $conf has the replacement values as a hash ref
$_ = ${$tmpl->render( $_, $conf )} for values %config_hash ;
uri
More information about the Losangeles-pm
mailing list