[LA.pm] What to call a small module
Tony
tony at metracom.com
Mon Apr 30 21:01:03 PDT 2012
My 2 cents.
Template::HashExpand
On Monday 30 April 2012 20:54:06 Uri Guttman wrote:
> 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
> _______________________________________________
> Losangeles-pm mailing list
> Losangeles-pm at pm.org
> http://mail.pm.org/mailman/listinfo/losangeles-pm
More information about the Losangeles-pm
mailing list