Hey Alistair, > $m->comp('component.html', $foo ? (foo => $foo) : ());
> Does seem slightly mucky, but it does do the job. Thanks. I take it >this is expected behaviour then? And it does lead me to wonder quite >how it works if an empty list works but an empty scalar doesn't ... I think you're looking at wrongly. If foo is true, you're going to get $m->comp( $component, foo => $foo ); Otherwise, you're going to get $m->comp( $component, () ); ^^^ no parameters are being sent through :) What you could have in your component is something like: my %DEFAULT = ( key1 => $value1, key2 => $value2, ... ); foreach my $key ( grep { not defined $ARGS{$key} } keys %ARGS ) { $ARGS{$key} = $DEFAULT{$key} } Alfie -- http://www.Share-House.com.au FREE Share House Advertising On Sat, Mar 8, 2008 at 1:07 AM, Hans Dieter Pearcey <[EMAIL PROTECTED]> wrote: > On Fri, Mar 07, 2008 at 01:54:24PM +0000, Alastair Douglas wrote: > > Does seem slightly mucky, but it does do the job. Thanks. I take it > > this is expected behaviour then? And it does lead me to wonder quite > > how it works if an empty list works but an empty scalar doesn't ... > > Replace "an empty list" with "an empty list of key/value pairs", and "an > empty > scalar" (no such thing, btw) with "a single key with an undefined value", and > it should be clearer. > > <%args> must work this way, because otherwise this would never work: > > <%args> > $foo => 17 > </%args> > if (defined $foo) { > # do some foo stuff > } > > # elsewhere > > # does some foo stuff > <& mycomp, foo => 0 &> > > # doesn't do some foo stuff > <& mycomp, foo => undef &> > > hdp. > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Mason-users mailing list > Mason-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mason-users > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users