Здравствуйте, Andrew.
Вы писали 29 апреля 2009 г., 15:37:31:
>> А меня в последнее время прет
>> print qq{ <head> { wow <title>$MyTitle</title> @{[ do{ 1+3 }]} zzz }
>> </head> };
> Самый необычный и интересный "шаблонизатор" - это Template::Declare:
template simple =>> sub {
> html {
> head {}
> body {
> p {'Hello, world wide web!'}
> }
> }
> };
о! а идея причесать хешами, а то не все работает если так-
use strict;
our $AUTOLOAD;
sub tag (@) {
my $t = shift;
my $p = shift if ref $_[0] eq 'HASH';
return "<$t" . ( join ' ', map { qq{ $_="$p->{$_}"} } keys %$p ) . ">" .
join( '', @_ ) . "</$t>";
}
sub UNIVERSAL::AUTOLOAD {
local $_ = $UNIVERSAL::AUTOLOAD;
s/(.*):://;
#print "[[$UNIVERSAL::AUTOLOAD];<$_> \...@_= ".join(':',@_)."]\n"; #debug
return tag $_, tag shift, @_ if $1 and $1 eq $_[0];
return tag $_, @_;
}
print html( body( a( { href => 'http://perl.org' }, h1('ruby sux') ) ) ), "\n";
#ok
#print html body a {'href' => 'http://perl.org' }, h1 ('ruby sux'), "\n"; #wrong
print html body a( { href => 'http://perl.org' }, h1('ruby sux') );
print "\n";
#ok
#print html body a ({href => 'http://perl.org' }, h1 'ruby sux'); print"\n";
#error
print html('in'), "\n";
#ok
#print html 'sux', body('in'), "\n"; #empty
print html body h1('sux'), a( { href => 'shit' }, 'ruby' ), p( h2('z') );
#ok
#print html body h1({z=>2},'ruby sux'), a 'text'; #err
--
С уважением,
Oleg mailto:[email protected]
--
Moscow.pm mailing list
[email protected] | http://moscow.pm.org