[Jifty-commit] r2251 - Template-Declare/lib/Template/Declare
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Dec 1 05:26:17 EST 2006
Author: audreyt
Date: Fri Dec 1 05:26:17 2006
New Revision: 2251
Modified:
Template-Declare/lib/Template/Declare/Tags.pm
Log:
* T::D::Tags - Tidy up and avoid redefinition warning.
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 05:26:17 2006
@@ -4,24 +4,34 @@
package Template::Declare::Tags;
use vars qw/@EXPORT @EXPORT_OK $self/;
use base 'Exporter';
- at EXPORT = qw( with template private show get_current_attr outs in_isolation $self
- Tr td ); # these two warns the user to use row/cell instead
+ at EXPORT =
+ qw( with template private show get_current_attr outs in_isolation $self
+ Tr td ); # these two warns the user to use row/cell instead
-our $DEPTH = 0;
+our $DEPTH = 0;
our %ATTRIBUTES = ();
-our $BUFFER = '';
+our $BUFFER = '';
-sub Tr (&) { die "Tr {...} and td {...} are invalid; use row {...} and cell {...} instead." }
-sub td (&) { die "Tr {...} and td {...} are invalid; use row {...} and cell {...} instead." }
+sub Tr (&) {
+ die "Tr {...} and td {...} are invalid; use row {...} and cell {...} instead.";
+}
+
+sub td (&) {
+ die "Tr {...} and td {...} are invalid; use row {...} and cell {...} instead.";
+}
-sub outs { $BUFFER .= join('',grep { defined } @_); return ''; }
+sub outs {
+ $BUFFER .= join( '', grep { defined } @_ );
+ return '';
+}
sub template ($$) {
my $template_name = shift;
- my $coderef = shift;
- my $caller = (caller(0))[0];
+ my $coderef = shift;
+ my $caller = ( caller(0) )[0];
+
+ no warnings qw( uninitialized redefine );
- no warnings 'uninitialized';
# template "foo" ==> CallerPkg::_jifty_template_foo;
# template "foo/bar" ==> CallerPkg::foo::_jifty_template_bar;
$template_name =~ s{(.*/)?(.*)}{${caller}::$1_jifty_template_$2};
@@ -32,23 +42,23 @@
}
sub get_current_attr ($) {
- $ATTRIBUTES{$_[0]};
+ $ATTRIBUTES{ $_[0] };
}
sub private ($) {
}
our %TagAlternateSpelling = (
- tr => 'row',
- td => 'cell',
- base => '', # Currently 'base' has no alternate spellings; simply ignore it
+ tr => 'row',
+ td => 'cell',
+ base => '', # Currently 'base' has no alternate spellings; simply ignore it
);
sub install_tag {
- my $tag = lc($_[0]);
+ my $tag = lc( $_[0] );
my $name = $tag;
- if (exists($TagAlternateSpelling{$tag})) {
+ if ( exists( $TagAlternateSpelling{$tag} ) ) {
$name = $TagAlternateSpelling{$tag} or return;
}
@@ -59,12 +69,10 @@
*$name = sub (&) { local *__ANON__ = $tag; _tag(@_) };
}
-
use CGI ();
our %TAGS = (
- map { $_ => +{} }
- map { @$_ }
- @CGI::EXPORT_TAGS{qw/:html2 :html3 :html4 :netscape :form/}
+ map { $_ => +{} }
+ map { @$_ } @CGI::EXPORT_TAGS{qw/:html2 :html3 :html4 :netscape :form/}
);
install_tag($_) for keys %TAGS;
@@ -80,20 +88,20 @@
sub _tag {
my $code = shift;
- my ($package, $filename, $line, $subroutine, $hasargs,
+ my (
+ $package, $filename, $line, $subroutine, $hasargs,
$wantarray, $evaltext, $is_require, $hints, $bitmask
- )
- = caller(1);
+ ) = caller(1);
# This is the hash of attributes filled in by attr() calls in the code;
my $tag = $subroutine;
$tag =~ s/^.*\:\://;
- my $buf = "\n" . ( " " x $DEPTH ) . "<$tag" . join( '',
+ my $buf = "\n" . ( " " x $DEPTH ) . "<$tag"
+ . join( '',
map { qq{ $_="} . ( $ATTRIBUTES{$_} || '' ) . qq{"} }
- keys %ATTRIBUTES
- );
+ keys %ATTRIBUTES );
{
no warnings qw( uninitialized redefine once );
@@ -136,7 +144,8 @@
$BUFFER .= $buf;
$BUFFER .= "\n" . ( " " x $DEPTH ) if ( $buf =~ /\n/ );
$BUFFER .= "</$tag>";
- } else {
+ }
+ else {
$BUFFER .= "/>";
}
return '';
@@ -155,13 +164,13 @@
sub show {
$self = shift if ( $_[0]->isa('Template::Declare') );
my $template = shift;
- my $buf = '';
+ my $buf = '';
{
local $BUFFER = '';
my $callable;
- if (ref($template) eq 'CODE') {
+ if ( ref($template) eq 'CODE' ) {
$callable = $template;
}
else {
@@ -170,7 +179,7 @@
# may want to just use the return value of has_template eventually
if ($callable) {
- &$callable($self, @_);
+ &$callable( $self, @_ );
}
$buf = $BUFFER;
More information about the Jifty-commit
mailing list