Author: nbubna
Date: Sat Mar 27 19:39:04 2010
New Revision: 928253
URL: http://svn.apache.org/viewvc?rev=928253&view=rev
Log:
handle blockinput more elegantly and efficiently
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java?rev=928253&r1=928252&r2=928253&view=diff
==============================================================================
---
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java
(original)
+++
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java
Sat Mar 27 19:39:04 2010
@@ -159,9 +159,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)
@@ -192,8 +194,7 @@ public class Parse extends InputBase
try
{
- if (!blockinput)
- t = rsvc.getTemplate( arg, getInputEncoding(context) );
+ t = rsvc.getTemplate( arg, getInputEncoding(context) );
}
catch ( ResourceNotFoundException rnfe )
{
@@ -253,11 +254,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 )
{
@@ -287,11 +287,8 @@ public class Parse extends InputBase
}
finally
{
- if (!blockinput)
- {
- context.popCurrentTemplateName();
- postRender(context);
- }
+ context.popCurrentTemplateName();
+ postRender(context);
}
/*