[Jifty-commit] r5801 - Template-Declare/lib/Template
Jifty commits
jifty-commit at lists.jifty.org
Mon Sep 8 08:52:31 EDT 2008
Author: sunnavy
Date: Mon Sep 8 08:52:31 2008
New Revision: 5801
Modified:
Template-Declare/lib/Template/Declare.pm
Log:
add a pitfall for the counterintutive output of "p { if ( 0 ) { } }"
Modified: Template-Declare/lib/Template/Declare.pm
==============================================================================
--- Template-Declare/lib/Template/Declare.pm (original)
+++ Template-Declare/lib/Template/Declare.pm Mon Sep 8 08:52:31 2008
@@ -740,6 +740,26 @@
p { 'hello, world!' }
+=item *
+
+Look out! If the if block is the last block/statement and the condition part is evaluated to be 0:
+
+ p { if ( 0 ) { } }
+
+produces
+
+ <p>0</p>
+
+instead of the more intutive output:
+
+ <p></p>
+
+This's because 0 is the last expression, so it's returned as the value of the whole block, which is used as the content of <p> tag.
+
+To get rid of this, just put an empty string at the end so it returns empty string as the content instead of 0:
+
+ p { if ( 0 ) { } '' }
+
=back
=head1 BUGS
More information about the Jifty-commit
mailing list