> On Mon, Oct 29, 2001 at 11:19:55AM +0100, [EMAIL PROTECTED] wrote:
> > I would like to use arrays or hashes with the values I now store in
> > this different variables. But when I use an array or a hash with the
> > DEFAULT-directive, the values are only set, when the array or hash itself
> > is not defined yet, but I would need to have alle the individual array- or
> > hash-elements set, that are not defined.
> 
> You can use DEFAULT to set individual elements in an array or hash.
> Something like this:
>   
>   [% cols = [ 'red' 'green' ] %]
> 
>   [% DEFAULT
>       cols.0 = 'scarlet'     # doesn't get set, cols.0 is defined
>       cols.2 = 'blue'        # does get set, cols.2 is undefined
>   %]
> 
>   [% cols.join %]            # red green blue

Another way is to use import to merge a hash of default values with a
hash of new values.

    [% defaultParams = {
            color0 => 'red',
            color1 => 'green',
            color2 => 'blue',
       };
       defaultParams.import(userParams);
    %]

You can then set the userParams hash however you want, and when
you PROCESS the above code any settings in the userParams hash
will override the defaults in defaultParams.

Craig


Reply via email to