[Html-widget] attributes

A. Pagaltzis pagaltzis at gmx.de
Fri Sep 22 15:30:42 CEST 2006


* Carl Franks <fireartist at gmail.com> [2006-09-22 14:50]:
> We can already do:
> $w->element( 'Textfield', 'foo' )
>     ->size( 10 )
>     ->attributes->{disabled} = 'disabled' ;
> But this isn't great, as you can't add further methods onto the
> method-chain.

    my $attributes = sub {
        my $self = shift;
        my $attr = $self->attributes;
        my ( $k, $v );
        $attr->{ $k } = $v while ( $k, $v ) = splice @_, 0, 2;
        return $self;
    };

    $w->element( 'Textfield', 'foo' )
        ->$attributes( disabled => 'disabled' )
        ->size( 10 );

Devious regards,
-- 
#Aristotle
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
&Just->another->Perl->hacker;



More information about the Html-widget mailing list