Hi,

thanks for __counter__ and <tmpl_var default> in version 2.6.

I'd like to suggest another feature:
setting hashrefs as template parameters with the effect that 
HTML::Template retrieves all key/value-pairs from the hashref and sets 
corresponding parameters.
The parameters follow a hierarchical naming scheme, so that you do not 
run into name-clashes and can easily keep track where the parameters are 
coming from.

Use like this:

$html->param('test'=>
                {
                'a' =>
                        {'a' => 1, 'b' => 2},
                'b' =>
                        {'c'=>3, 'd'=>4}
                }
);

to set

<tmpl_var name='test/a/a'>
<tmpl_var name='test/a/b'>
<tmpl_var name='test/b/c'>
<tmpl_var name='test/b/d'>

Anyone else think this is useful?


Cheers,

Thilo Planz

===================

Here is the patch:

     # if the value is a hashref,
     # construct parameters from its key/value-pairs
     # and set them using recursion
     if (ref $value and UNIVERSAL::isa($value, 'HASH')){
        foreach (keys %$value){
                $self->param(($param.'/'.$_)=>$value->{$_});
        }
        return;
     }

these lines go into HTML::Template (method param), just before

  # check that this param exists in the template
     $options->{die_on_bad_params} and !exists($param_map->{$param}) and
       croak("HTML::Template : Attempt to set nonexistent parameter 
'$param' - this parameter name doesn't match any declarations in the 
template file : (die_on_bad_params => 1)");

======================

PS:

I wouldn't try to stuff a hashref that contains recursive references 
into the method.....



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to