PATCH: omit omit-tag from templates
Jonathan Vanasco <[email protected]> Tue, 1 Aug 2006 18:49:03 -0400
| Newsgroups | gmane.comp.lang.perl.modules.petal |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail-2-71684860
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
This is a trivial patch...
I noticed while checking some petal cache documents that if omit-
tag="string:1" were set - which is the recommended way of always
omitting a tag from a document - it was turned into code that always
returned true
that seemed a bit wasteful. this patch just does a secondary check
on omit-tag items , to see if it is set to string:1
if it is, the start/end tags aren't pushed onto the result stack. if
its not , they are.
this seems to work fine, and respect nested items
--Apple-Mail-2-71684860
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
x-unix-mode=0644;
name=PETAL.diff
Content-Disposition: attachment;
filename=PETAL.diff
--- /Library/Perl/5.8.6/Petal/Canonicalizer/XHTML.dist 2005-09-15 09:42:35.000000000 -0400
+++ /Library/Perl/5.8.6/Petal/Canonicalizer/XHTML.pm 2006-08-01 18:35:23.000000000 -0400
@@ -167,15 +167,21 @@
{
if (defined $att->{"$petal:omit-tag"})
{
- my $expression = $att->{"$petal:omit-tag"} || 'string:1';
- $Petal::Canonicalizer::XML::NodeStack[$#Petal::Canonicalizer::XML::NodeStack]->{'omit-tag'} = $expression;
- push @Petal::Canonicalizer::XML::Result, (defined $att_str and $att_str) ?
- "<?if name=\"false:$expression\"?><$tag $att_str><?end?>" :
- "<?if name=\"false:$expression\"?><$tag><?end?>";
+ my $expression = $att->{"$petal:omit-tag"} || 'string:1';
+ $Petal::Canonicalizer::XML::NodeStack[$#Petal::Canonicalizer::XML::NodeStack]->{'omit-tag'} = $expression;
+ if ( $expression ne 'string:1' )
+ {
+ push @Petal::Canonicalizer::XML::Result,
+ (defined $att_str and $att_str)
+ ?
+ "<?if name=\"false:$expression\"?><$tag $att_str><?end?>"
+ :
+ "<?if name=\"false:$expression\"?><$tag><?end?>";
+ }
}
else
{
- push @Petal::Canonicalizer::XML::Result, (defined $att_str and $att_str) ? "<$tag $att_str>" : "<$tag>";
+ push @Petal::Canonicalizer::XML::Result, (defined $att_str and $att_str) ? "<$tag $att_str>" : "<$tag>";
}
}
@@ -224,7 +230,10 @@
if (defined $node->{'omit-tag'})
{
my $expression = $node->{'omit-tag'};
- push @Petal::Canonicalizer::XML::Result, "<?if name=\"false:$expression\"?></$tag><?end?>";
+ if ( $expression ne 'string:1' )
+ {
+ push @Petal::Canonicalizer::XML::Result, "<?if name=\"false:$expression\"?></$tag><?end?>";
+ }
}
else
{
--Apple-Mail-2-71684860
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
--Apple-Mail-2-71684860--