I have written a class with the following properties:
That way you can write:
HTML::Element::Whatever->new('input')->name("hallo")->value("welt")->size(10) and you get the HTML source for the appropriate input element.
This allows for some really concise generation of HTML.
Cool. (Score:1)
By the way.. (Score:1)
Re:By the way.. (Score:2)
I will eventually. Its only in internal use now where we don't need it passing the whole HTML element test suite.
Do you have a name suggestion?
Re:By the way.. (Score:1)
Re: (Score:1)
To be honest, I don’t think that’s particularly a good interface. Passing a hashref for attributes is both more obvious as well as more concise, syntax-wise.
I’m also never sure whether to like method chaining in general or not. It’s a kludge for Perl5; fortunately we won’t need it in Perl6.