[Jifty-commit] r2246 - Template-Declare/lib/Template/Declare
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Dec 1 03:58:27 EST 2006
Author: audreyt
Date: Fri Dec 1 03:58:26 2006
New Revision: 2246
Modified:
Template-Declare/lib/Template/Declare/Tags.pm
Log:
* Ditch the intermediate CURRENT_ATTRIBUTE structure; now all "attr is foo"
immediately emits attributes.
Modified: Template-Declare/lib/Template/Declare/Tags.pm
==============================================================================
--- Template-Declare/lib/Template/Declare/Tags.pm (original)
+++ Template-Declare/lib/Template/Declare/Tags.pm Fri Dec 1 03:58:26 2006
@@ -9,7 +9,6 @@
our $DEPTH = 0;
our %ATTRIBUTES = ();
-our %CURRENT_ATTRIBUTES = ();
our $BUFFER = '';
sub Tr (&) { die "tr {...} and td {...} are invalid; use row {...} and cell {...} instead." }
@@ -33,7 +32,7 @@
}
sub get_current_attr ($) {
- $CURRENT_ATTRIBUTES{$_[0]};
+ $ATTRIBUTES{$_[0]};
}
sub private ($) {
@@ -76,6 +75,7 @@
my $val = shift || '';
$ATTRIBUTES{$key} = $val;
}
+ '';
}
sub _tag {
@@ -90,29 +90,41 @@
my $tag = $subroutine;
$tag =~ s/^.*\:\://;
- my $buf;
+ my $buf = "\n" . ( " " x $DEPTH ) . "<$tag" . join( '',
+ map { qq{ $_="} . ( $ATTRIBUTES{$_} || '' ) . qq{"} }
+ keys %ATTRIBUTES
+ );
+
{
no warnings qw( uninitialized redefine once );
local $BUFFER;
local $DEPTH = $DEPTH + 1;
- local %CURRENT_ATTRIBUTES = %ATTRIBUTES;
%ATTRIBUTES = ();
local *is::AUTOLOAD = sub {
+ shift;
+
my $field = our $AUTOLOAD;
$field =~ s/.*:://;
- $CURRENT_ATTRIBUTES{$field} = join(' ', @_[1..$#_]);
+ my $val = "@_";
+
+ use bytes;
+ $val =~ s/&/&/g;
+ $val =~ s/</</g;
+ $val =~ s/>/>/g;
+ $val =~ s/\(/(/g;
+ $val =~ s/\)/)/g;
+ $val =~ s/"/"/g;
+ $val =~ s/'/'/g;
+
+ $buf .= qq[ $field="$val"];
'';
};
my $last = $code->();
- $buf = "\n" . ( " " x ($DEPTH-1) ) . "<$tag"
- . join( '',
- map { qq{ $_="} . ( $CURRENT_ATTRIBUTES{$_} || '' ) . qq{"} }
- keys %CURRENT_ATTRIBUTES) . '>';
-
+ $buf .= '>';
$buf .= $BUFFER;
# We concatenate "" to force scalarization when $last or $BUFFER is solely a Jifty::Web::Link
More information about the Jifty-commit
mailing list