hello,
i'm trying to ease the production of xml streams in a perl6 script so i
wrote
sub _attrs_str ( %attrs) {
%attrs.pairs.map: { qq/{.key}="{.value}"/ }
}
multi sub tag ( Str $tag, Parcel $attrs=()) {
"<{ $tag, _attrs_str $attrs.hash }/>";
}
multi sub tag ( Parcel $spec ) { tag $spec[0], $spec[1..*] }
now i can write
say tag < img src /images/logo.png >;
to produce
<img src="/images/logo.png"/>
the next step is to write
say img < src /images/logo.png >;
to get the same content. i also want to have link and meta helpers. what
i would like to write is
$?PACKAGE.
< link meta img >.map: {
$?PACKAGE.^add_method\
( $?PACKAGE
, $_
, &tag.assuming( tag => $_ ) )
}
but $?PACKAGE.HOW is a PackageHOW and add_method comes with ClassHOW. if
someone can give me some clue ?
thanks and regards
--
Marc Chantreux
Université de Strasbourg, Direction Informatique
14 Rue René Descartes,
67084 STRASBOURG CEDEX
☎: 03.68.85.57.40
http://unistra.fr
"Don't believe everything you read on the Internet"
-- Abraham Lincoln