velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r928252 - /velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java
Date Sat, 27 Mar 2010 19:34:23 GMT
Author: nbubna
Date: Sat Mar 27 19:34:23 2010
New Revision: 928252

URL: http://svn.apache.org/viewvc?rev=928252&view=rev
Log:
handle blockinput more elegantly and efficiently

Modified:
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java?rev=928252&r1=928251&r2=928252&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java
Sat Mar 27 19:34:23 2010
@@ -178,9 +178,11 @@ public class Parse extends InputBase
          *   a null return value from the event cartridge indicates we should not
          *   input a resource.
          */
-        boolean blockinput = false;
         if (arg == null)
-            blockinput = true;
+        {
+            // abort early, but still consider it a successful rendering
+            return true;
+        }
 
 
         if (maxDepth > 0)
@@ -211,8 +213,7 @@ public class Parse extends InputBase
 
         try
         {
-            if (!blockinput)
-                t = rsvc.getTemplate( arg, getInputEncoding(context) );
+            t = rsvc.getTemplate( arg, getInputEncoding(context) );
         }
         catch ( ResourceNotFoundException rnfe )
         {
@@ -272,12 +273,10 @@ public class Parse extends InputBase
          */
         try
         {
-            if (!blockinput) {
-                preRender(context);
-                context.pushCurrentTemplateName(arg);
-                
-                ((SimpleNode) t.getData()).render(context, writer);
-            }
+            preRender(context);
+            context.pushCurrentTemplateName(arg);
+
+            ((SimpleNode) t.getData()).render(context, writer);
         }
         catch( StopCommand stop )
         {
@@ -307,11 +306,8 @@ public class Parse extends InputBase
         }
         finally
         {
-            if (!blockinput)
-            {
-                context.popCurrentTemplateName();
-                postRender(context);
-            }
+            context.popCurrentTemplateName();
+            postRender(context);
         }
 
         /*



Mime
View raw message