[interchange-cvs] interchange - jon modified 2 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Wed Feb 11 09:34:33 EST 2004


User:      jon
Date:      2004-02-11 14:34:33 GMT
Modified:  lib/Vend Config.pm Parse.pm
Log:
Add new UserTag option "attrDefault", which allows default attributes to
be set globally or catalog-wide for a given usertag. Two examples:

UserTag area attrDefault href index
UserTag calc attrDefault filter entities

Any user-specified attributes will take precedence, even if 0 or blank.

This is designed to allow changing the default behavior of a tag without
changing its code, especially for built-in tags one would rather not
customize. Note that when using this directive on global usertags,
it must be done in interchange.cfg, and for catalog usertags in catalog.cfg.

Revision  Changes    Path
2.132     +4 -2      interchange/lib/Vend/Config.pm


rev 2.132, prev_rev 2.131
Index: Config.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.131
retrieving revision 2.132
diff -u -u -r2.131 -r2.132
--- Config.pm	26 Jan 2004 09:18:46 -0000	2.131
+++ Config.pm	11 Feb 2004 14:34:33 -0000	2.132
@@ -1,6 +1,6 @@
 # Vend::Config - Configure Interchange
 #
-# $Id: Config.pm,v 2.131 2004/01/26 09:18:46 racke Exp $
+# $Id: Config.pm,v 2.132 2004/02/11 14:34:33 jon Exp $
 #
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -48,7 +48,7 @@
 use Vend::File;
 use Vend::Data;
 
-$VERSION = substr(q$Revision: 2.131 $, 10);
+$VERSION = substr(q$Revision: 2.132 $, 10);
 
 my %CDname;
 my %CPname;
@@ -3637,6 +3637,7 @@
 	alias			Alias
 	addattr  		addAttr
 	attralias		attrAlias
+	attrdefault		attrDefault
 	cannest			canNest
 	description  	Description
 	documentation	Documentation
@@ -3662,6 +3663,7 @@
 my %tagHash	= ( qw!
                 attrAlias   1
                 Implicit    1
+				attrDefault	1
 				! );
 my %tagBool = ( qw!
                 ActionMap   1



2.29      +22 -2     interchange/lib/Vend/Parse.pm


rev 2.29, prev_rev 2.28
Index: Parse.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Parse.pm,v
retrieving revision 2.28
retrieving revision 2.29
diff -u -u -r2.28 -r2.29
--- Parse.pm	23 Jun 2003 16:44:40 -0000	2.28
+++ Parse.pm	11 Feb 2004 14:34:33 -0000	2.29
@@ -1,6 +1,6 @@
 # Vend::Parse - Parse Interchange tags
 # 
-# $Id: Parse.pm,v 2.28 2003/06/23 16:44:40 mheins Exp $
+# $Id: Parse.pm,v 2.29 2004/02/11 14:34:33 jon Exp $
 #
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -36,7 +36,7 @@
 
 @ISA = qw(Exporter Vend::Parser);
 
-$VERSION = substr(q$Revision: 2.28 $, 10);
+$VERSION = substr(q$Revision: 2.29 $, 10);
 
 @EXPORT = ();
 @EXPORT_OK = qw(find_matching_end);
@@ -245,6 +245,8 @@
 						},
 );
 
+my %attrDefault;
+
 my %Alias = (
 
 				qw(
@@ -383,6 +385,7 @@
      Alias           => \%Alias,
      addAttr         => \%addAttr,
      attrAlias       => \%attrAlias,
+     attrDefault     => \%attrDefault,
 	 Documentation   => \%Documentation,
 	 hasEndTag       => \%hasEndTag,
 	 NoReparse       => \%NoReparse,
@@ -465,6 +468,14 @@
 			$ref->{$v} = $ref->{$k};
 		}
 	}
+	if (defined $attrDefault{$tag}) {
+		my ($k, $v);
+		while (($k, $v) = each %{$attrDefault{$tag}}) {
+			next if defined $ref->{$k};
+#::logDebug("using default $k = $v");
+			$ref->{$k} = $v;
+		}
+	}
 	@list = @{$ref}{@{$Order{$tag}}};
 	push @list, $ref if defined $addAttr{$tag};
 	push @list, (shift || $ref->{body} || '') if $hasEndTag{$tag};
@@ -655,6 +666,15 @@
 		my $p = new Vend::Parse;
 		$p->parse($attr->{$trib});
 		$attr->{$trib} = ${$p->{OUT}};
+	}
+
+	if (defined $attrDefault{$tag}) {
+		my ($k, $v);
+		while (($k, $v) = each %{$attrDefault{$tag}}) {
+			next if defined $attr->{$k};
+#::logDebug("using default $k = $v");
+			$attr->{$k} = $v;
+		}
 	}
 
 	$attr->{enable_html} = 1 if $Vend::Cfg->{Promiscuous};








More information about the interchange-cvs mailing list