freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [01/23] incubator-freemarker git commit: let TemplateElement#accept return child elements that remain to be processed
Date Tue, 15 Dec 2015 23:26:06 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/master 407b6b8b1 -> 88d5c7f3d


let TemplateElement#accept return child elements that remain to be processed


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/699d4426
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/699d4426
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/699d4426

Branch: refs/heads/master
Commit: 699d4426e03ec142b8f2341cb57b33ec7ff7906c
Parents: 8adee32
Author: Moritz Kleine <moritz.kleine@coremedia.com>
Authored: Wed Sep 9 22:17:24 2015 +0200
Committer: Moritz Kleine <moritz.kleine@coremedia.com>
Committed: Wed Oct 14 14:18:33 2015 +0200

----------------------------------------------------------------------
 src/main/java/freemarker/core/Assignment.java   |  3 +-
 .../freemarker/core/AssignmentInstruction.java  |  8 ++---
 src/main/java/freemarker/core/AttemptBlock.java |  3 +-
 src/main/java/freemarker/core/AutoEscBlock.java |  6 ++--
 .../java/freemarker/core/BlockAssignment.java   |  3 +-
 .../java/freemarker/core/BodyInstruction.java   |  3 +-
 .../java/freemarker/core/BreakInstruction.java  |  2 +-
 src/main/java/freemarker/core/Case.java         |  6 ++--
 src/main/java/freemarker/core/Comment.java      |  3 +-
 .../java/freemarker/core/CompressedBlock.java   |  3 +-
 .../java/freemarker/core/ConditionalBlock.java  |  7 ++---
 src/main/java/freemarker/core/DebugBreak.java   |  6 ++--
 .../java/freemarker/core/DollarVariable.java    |  3 +-
 src/main/java/freemarker/core/ElseOfList.java   |  6 ++--
 src/main/java/freemarker/core/Environment.java  | 20 +++++++++++--
 src/main/java/freemarker/core/EscapeBlock.java  | 10 +++----
 .../freemarker/core/FallbackInstruction.java    |  3 +-
 .../java/freemarker/core/FlushInstruction.java  |  3 +-
 src/main/java/freemarker/core/IfBlock.java      |  6 ++--
 src/main/java/freemarker/core/Include.java      |  3 +-
 src/main/java/freemarker/core/Items.java        |  3 +-
 .../java/freemarker/core/IteratorBlock.java     |  3 +-
 src/main/java/freemarker/core/LibraryLoad.java  |  3 +-
 .../java/freemarker/core/ListElseContainer.java |  5 ++--
 src/main/java/freemarker/core/Macro.java        |  3 +-
 src/main/java/freemarker/core/MixedContent.java |  7 ++---
 .../java/freemarker/core/NoAutoEscBlock.java    |  6 ++--
 .../java/freemarker/core/NoEscapeBlock.java     |  6 ++--
 .../java/freemarker/core/NumericalOutput.java   |  3 +-
 .../java/freemarker/core/OutputFormatBlock.java |  6 ++--
 .../java/freemarker/core/PropertySetting.java   |  3 +-
 .../java/freemarker/core/RecoveryBlock.java     |  6 ++--
 src/main/java/freemarker/core/RecurseNode.java  |  3 +-
 .../java/freemarker/core/ReturnInstruction.java |  3 +-
 src/main/java/freemarker/core/Sep.java          |  5 ++--
 .../java/freemarker/core/StopInstruction.java   |  2 +-
 src/main/java/freemarker/core/SwitchBlock.java  |  3 +-
 .../java/freemarker/core/TemplateElement.java   |  9 +++++-
 .../core/TemplateElementsToVisit.java           | 31 ++++++++++++++++++++
 src/main/java/freemarker/core/TextBlock.java    |  3 +-
 ...nterruptionSupportTemplatePostProcessor.java |  3 +-
 .../java/freemarker/core/TransformBlock.java    |  3 +-
 .../java/freemarker/core/TrimInstruction.java   |  3 +-
 src/main/java/freemarker/core/UnifiedCall.java  |  5 ++--
 src/main/java/freemarker/core/VisitNode.java    |  3 +-
 45 files changed, 147 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/Assignment.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Assignment.java b/src/main/java/freemarker/core/Assignment.java
index 0521250..9ec1df7 100644
--- a/src/main/java/freemarker/core/Assignment.java
+++ b/src/main/java/freemarker/core/Assignment.java
@@ -101,7 +101,7 @@ final class Assignment extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException {
         final Environment.Namespace namespace;
         if (namespaceExp == null) {
             switch (scope) {
@@ -193,6 +193,7 @@ final class Assignment extends TemplateElement {
         } else {
             namespace.put(variableName, value);
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/AssignmentInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/AssignmentInstruction.java b/src/main/java/freemarker/core/AssignmentInstruction.java
index d575ca2..3135876 100644
--- a/src/main/java/freemarker/core/AssignmentInstruction.java
+++ b/src/main/java/freemarker/core/AssignmentInstruction.java
@@ -51,12 +51,8 @@ final class AssignmentInstruction extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
-        int ln = getRegulatedChildCount();
-        for (int i = 0; i < ln; i++) {
-            Assignment assignment = (Assignment) getRegulatedChild(i);
-            env.visit(assignment);
-        }
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
+        return new TemplateElementsToVisit(getRegulatedChildren());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/AttemptBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/AttemptBlock.java b/src/main/java/freemarker/core/AttemptBlock.java
index be82cf2..2af619f 100644
--- a/src/main/java/freemarker/core/AttemptBlock.java
+++ b/src/main/java/freemarker/core/AttemptBlock.java
@@ -40,8 +40,9 @@ final class AttemptBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         env.visitAttemptRecover(attemptBlock, recoveryBlock);
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/AutoEscBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/AutoEscBlock.java b/src/main/java/freemarker/core/AutoEscBlock.java
index ce23189..58c188a 100644
--- a/src/main/java/freemarker/core/AutoEscBlock.java
+++ b/src/main/java/freemarker/core/AutoEscBlock.java
@@ -33,10 +33,8 @@ final class AutoEscBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
-        if (getNestedBlock() != null) {
-            env.visitByHiddingParent(getNestedBlock());
-        }
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
+        return new TemplateElementsToVisit(getNestedBlock(), true);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/BlockAssignment.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BlockAssignment.java b/src/main/java/freemarker/core/BlockAssignment.java
index d86c724..4b054b2 100644
--- a/src/main/java/freemarker/core/BlockAssignment.java
+++ b/src/main/java/freemarker/core/BlockAssignment.java
@@ -49,7 +49,7 @@ final class BlockAssignment extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         if (getNestedBlock() != null) {
             env.visitAndTransform(getNestedBlock(), new CaptureOutput(env), null);
         } else {
@@ -65,6 +65,7 @@ final class BlockAssignment extends TemplateElement {
                 env.setLocalVariable(varName, value);
             }
         }
+        return null;
     }
 
     private TemplateModel capturedStringToModel(String s) throws TemplateModelException {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/BodyInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BodyInstruction.java b/src/main/java/freemarker/core/BodyInstruction.java
index 161c293..9d7db0d 100644
--- a/src/main/java/freemarker/core/BodyInstruction.java
+++ b/src/main/java/freemarker/core/BodyInstruction.java
@@ -55,9 +55,10 @@ final class BodyInstruction extends TemplateElement {
      * I (JR) realized this thanks to some incisive comments from Daniel Dekany.
      */
     @Override
-    void accept(Environment env) throws IOException, TemplateException {
+    TemplateElementsToVisit accept(Environment env) throws IOException, TemplateException {
         Context bodyContext = new Context(env);
         env.invokeNestedContent(bodyContext);
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/BreakInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/BreakInstruction.java b/src/main/java/freemarker/core/BreakInstruction.java
index dc76f68..0690c7a 100644
--- a/src/main/java/freemarker/core/BreakInstruction.java
+++ b/src/main/java/freemarker/core/BreakInstruction.java
@@ -25,7 +25,7 @@ package freemarker.core;
 final class BreakInstruction extends TemplateElement {
 
     @Override
-    void accept(Environment env) {
+    TemplateElementsToVisit accept(Environment env) {
         throw Break.INSTANCE;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/Case.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Case.java b/src/main/java/freemarker/core/Case.java
index 0897b2d..57eebad 100644
--- a/src/main/java/freemarker/core/Case.java
+++ b/src/main/java/freemarker/core/Case.java
@@ -39,11 +39,9 @@ final class Case extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) 
+    TemplateElementsToVisit accept(Environment env)
         throws TemplateException, IOException {
-        if (getNestedBlock() != null) {
-            env.visitByHiddingParent(getNestedBlock());
-        }
+        return new TemplateElementsToVisit(getNestedBlock(), true);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/Comment.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Comment.java b/src/main/java/freemarker/core/Comment.java
index 94e8a92..c2d5a95 100644
--- a/src/main/java/freemarker/core/Comment.java
+++ b/src/main/java/freemarker/core/Comment.java
@@ -37,8 +37,9 @@ public final class Comment extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) {
+    TemplateElementsToVisit accept(Environment env) {
         // do nothing, skip the body
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/CompressedBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/CompressedBlock.java b/src/main/java/freemarker/core/CompressedBlock.java
index 702b3c8..54794d6 100644
--- a/src/main/java/freemarker/core/CompressedBlock.java
+++ b/src/main/java/freemarker/core/CompressedBlock.java
@@ -36,10 +36,11 @@ final class CompressedBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         if (getNestedBlock() != null) {
             env.visitAndTransform(getNestedBlock(), StandardCompress.INSTANCE, null);
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/ConditionalBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/ConditionalBlock.java b/src/main/java/freemarker/core/ConditionalBlock.java
index cbc1b40..34ac90c 100644
--- a/src/main/java/freemarker/core/ConditionalBlock.java
+++ b/src/main/java/freemarker/core/ConditionalBlock.java
@@ -45,12 +45,11 @@ final class ConditionalBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         if (condition == null || condition.evalToBoolean(env)) {
-            if (getNestedBlock() != null) {
-                env.visitByHiddingParent(getNestedBlock());
-            }
+            return new TemplateElementsToVisit(getNestedBlock(), true);
         }
+        return null;
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/DebugBreak.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/DebugBreak.java b/src/main/java/freemarker/core/DebugBreak.java
index 004db3d..11c1bdf 100644
--- a/src/main/java/freemarker/core/DebugBreak.java
+++ b/src/main/java/freemarker/core/DebugBreak.java
@@ -38,12 +38,12 @@ public class DebugBreak extends TemplateElement {
     }
     
     @Override
-    protected void accept(Environment env) throws TemplateException, IOException {
+    protected TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         if (!DebuggerService.suspendEnvironment(
                 env, this.getTemplate().getSourceName(), getNestedBlock().getBeginLine())) {
-            getNestedBlock().accept(env);
+            return getNestedBlock().accept(env);
         } else {
-            throw new StopException(env, "Stopped by debugger");        
+            throw new StopException(env, "Stopped by debugger");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/DollarVariable.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/DollarVariable.java b/src/main/java/freemarker/core/DollarVariable.java
index 2ecab8c..08767f9 100644
--- a/src/main/java/freemarker/core/DollarVariable.java
+++ b/src/main/java/freemarker/core/DollarVariable.java
@@ -55,7 +55,7 @@ final class DollarVariable extends Interpolation {
      * Outputs the string value of the enclosed expression.
      */
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         final Object moOrStr = calculateInterpolatedStringOrMarkup(env);
         final Writer out = env.getOut();
         if (moOrStr instanceof String) {
@@ -88,6 +88,7 @@ final class DollarVariable extends Interpolation {
                 moOF.output(mo, out);
             }
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/ElseOfList.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/ElseOfList.java b/src/main/java/freemarker/core/ElseOfList.java
index 9741d15..065f581 100644
--- a/src/main/java/freemarker/core/ElseOfList.java
+++ b/src/main/java/freemarker/core/ElseOfList.java
@@ -33,10 +33,8 @@ final class ElseOfList extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
-        if (getNestedBlock() != null) {
-            env.visitByHiddingParent(getNestedBlock());
-        }
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
+        return new TemplateElementsToVisit(getNestedBlock(), true);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/Environment.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Environment.java b/src/main/java/freemarker/core/Environment.java
index 358c371..2e6b480 100644
--- a/src/main/java/freemarker/core/Environment.java
+++ b/src/main/java/freemarker/core/Environment.java
@@ -319,7 +319,7 @@ public final class Environment extends Configurable {
             throws TemplateException, IOException {
         pushElement(element);
         try {
-            element.accept(this);
+            accept(element);
         } catch (TemplateException te) {
             handleTemplateException(te);
         } finally {
@@ -327,6 +327,22 @@ public final class Environment extends Configurable {
         }
     }
 
+    private void accept(TemplateElement element) throws TemplateException, IOException {
+        TemplateElementsToVisit templateElementsToVisit = element.accept(this);
+        if(null != templateElementsToVisit) {
+            boolean hideInParent = templateElementsToVisit.isHideInParent();
+            for (TemplateElement templateElement : templateElementsToVisit.getTemplateElements()) {
+                if(null != templateElement) {
+                    if(hideInParent) {
+                        visitByHiddingParent(templateElement);
+                    } else {
+                        visit(templateElement);
+                    }
+                }
+            }
+        }
+    }
+
     /**
      * Instead of pushing into the element stack, we replace the top element for the time the parameter element is
      * visited, and then we restore the top element. The main purpose of this is to get rid of elements in the error
@@ -338,7 +354,7 @@ public final class Environment extends Configurable {
             throws TemplateException, IOException {
         TemplateElement parent = replaceTopElement(element);
         try {
-            element.accept(this);
+            accept(element);
         } catch (TemplateException te) {
             handleTemplateException(te);
         } finally {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/EscapeBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/EscapeBlock.java b/src/main/java/freemarker/core/EscapeBlock.java
index da33316..be7ed51 100644
--- a/src/main/java/freemarker/core/EscapeBlock.java
+++ b/src/main/java/freemarker/core/EscapeBlock.java
@@ -19,11 +19,11 @@
 
 package freemarker.core;
 
-import java.io.IOException;
-
 import freemarker.core.Expression.ReplacemenetState;
 import freemarker.template.TemplateException;
 
+import java.io.IOException;
+
 /**
  * Representation of the compile-time #escape directive.
  */
@@ -47,10 +47,8 @@ class EscapeBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
-        if (getNestedBlock() != null) {
-            env.visit(getNestedBlock());
-        }
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
+        return new TemplateElementsToVisit(getNestedBlock(), false);
     }
 
     Expression doEscape(Expression expression) {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/FallbackInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/FallbackInstruction.java b/src/main/java/freemarker/core/FallbackInstruction.java
index a86f302..27f0da6 100644
--- a/src/main/java/freemarker/core/FallbackInstruction.java
+++ b/src/main/java/freemarker/core/FallbackInstruction.java
@@ -26,8 +26,9 @@ import freemarker.template.TemplateException;
 final class FallbackInstruction extends TemplateElement {
 
     @Override
-    void accept(Environment env) throws IOException, TemplateException {
+    TemplateElementsToVisit accept(Environment env) throws IOException, TemplateException {
         env.fallback();
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/FlushInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/FlushInstruction.java b/src/main/java/freemarker/core/FlushInstruction.java
index 1657395..d836909 100644
--- a/src/main/java/freemarker/core/FlushInstruction.java
+++ b/src/main/java/freemarker/core/FlushInstruction.java
@@ -27,8 +27,9 @@ import java.io.IOException;
 final class FlushInstruction extends TemplateElement {
 
     @Override
-    void accept(Environment env) throws IOException {
+    TemplateElementsToVisit accept(Environment env) throws IOException {
         env.getOut().flush();
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/IfBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/IfBlock.java b/src/main/java/freemarker/core/IfBlock.java
index d5d2ef7..2c15540 100644
--- a/src/main/java/freemarker/core/IfBlock.java
+++ b/src/main/java/freemarker/core/IfBlock.java
@@ -40,7 +40,7 @@ final class IfBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         int ln  = getRegulatedChildCount();
         for (int i = 0; i < ln; i++) {
             ConditionalBlock cblock = (ConditionalBlock) getRegulatedChild(i);
@@ -48,11 +48,11 @@ final class IfBlock extends TemplateElement {
             env.replaceElementStackTop(cblock);
             if (condition == null || condition.evalToBoolean(env)) {
                 if (cblock.getNestedBlock() != null) {
-                    env.visitByHiddingParent(cblock.getNestedBlock());
+                    return new TemplateElementsToVisit(cblock.getNestedBlock(), true);
                 }
-                return;
             }
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/Include.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Include.java b/src/main/java/freemarker/core/Include.java
index f18c314..745b5f1 100644
--- a/src/main/java/freemarker/core/Include.java
+++ b/src/main/java/freemarker/core/Include.java
@@ -118,7 +118,7 @@ final class Include extends TemplateElement {
     }
     
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         final String includedTemplateName = includedTemplateNameExp.evalAndCoerceToPlainText(env);
         final String fullIncludedTemplateName;
         try {
@@ -170,6 +170,7 @@ final class Include extends TemplateElement {
         if (includedTemplate != null) {
             env.include(includedTemplate);
         }
+        return null;
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/Items.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Items.java b/src/main/java/freemarker/core/Items.java
index eecc15f..25b8010 100644
--- a/src/main/java/freemarker/core/Items.java
+++ b/src/main/java/freemarker/core/Items.java
@@ -36,7 +36,7 @@ class Items extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         final IterationContext iterCtx = IteratorBlock.findEnclosingIterationContext(env, null);
         if (iterCtx == null) {
             // The parser should prevent this situation
@@ -45,6 +45,7 @@ class Items extends TemplateElement {
         }
         
         iterCtx.loopForItemsElement(env, getNestedBlock(), loopVarName);
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/IteratorBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/IteratorBlock.java b/src/main/java/freemarker/core/IteratorBlock.java
index 22b2164..d718aa1 100644
--- a/src/main/java/freemarker/core/IteratorBlock.java
+++ b/src/main/java/freemarker/core/IteratorBlock.java
@@ -63,8 +63,9 @@ final class IteratorBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         acceptWithResult(env);
+        return null;
     }
     
     boolean acceptWithResult(Environment env) throws TemplateException, IOException {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/LibraryLoad.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/LibraryLoad.java b/src/main/java/freemarker/core/LibraryLoad.java
index 9a9c887..05a83a5 100644
--- a/src/main/java/freemarker/core/LibraryLoad.java
+++ b/src/main/java/freemarker/core/LibraryLoad.java
@@ -50,7 +50,7 @@ public final class LibraryLoad extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         final String importedTemplateName = importedTemplateNameExp.evalAndCoerceToPlainText(env);
         final String fullImportedTemplateName;
         try {
@@ -71,6 +71,7 @@ public final class LibraryLoad extends TemplateElement {
                     "):\n", new _DelayedGetMessage(e));
         }
         env.importLib(importedTemplate, namespace);
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/ListElseContainer.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/ListElseContainer.java b/src/main/java/freemarker/core/ListElseContainer.java
index 34a67a9..a9c61e7 100644
--- a/src/main/java/freemarker/core/ListElseContainer.java
+++ b/src/main/java/freemarker/core/ListElseContainer.java
@@ -36,10 +36,11 @@ class ListElseContainer extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         if (!listPart.acceptWithResult(env)) {
-            elsePart.accept(env);
+            return elsePart.accept(env);
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/Macro.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Macro.java b/src/main/java/freemarker/core/Macro.java
index 52dd926..bfaab99 100644
--- a/src/main/java/freemarker/core/Macro.java
+++ b/src/main/java/freemarker/core/Macro.java
@@ -90,8 +90,9 @@ public final class Macro extends TemplateElement implements TemplateModel {
     }
 
     @Override
-    void accept(Environment env) {
+    TemplateElementsToVisit accept(Environment env) {
         env.visitMacroDef(this);
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/MixedContent.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/MixedContent.java b/src/main/java/freemarker/core/MixedContent.java
index c7a4c6e..274e520 100644
--- a/src/main/java/freemarker/core/MixedContent.java
+++ b/src/main/java/freemarker/core/MixedContent.java
@@ -50,12 +50,9 @@ final class MixedContent extends TemplateElement {
      * and outputs the resulting text.
      */
     @Override
-    void accept(Environment env) 
+    TemplateElementsToVisit accept(Environment env)
         throws TemplateException, IOException {
-        int ln = getRegulatedChildCount();
-        for (int i = 0; i < ln; i++) {
-            env.visit(getRegulatedChild(i));
-        }
+        return new TemplateElementsToVisit(getRegulatedChildren(), false);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/NoAutoEscBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/NoAutoEscBlock.java b/src/main/java/freemarker/core/NoAutoEscBlock.java
index d59c368..ffd394c 100644
--- a/src/main/java/freemarker/core/NoAutoEscBlock.java
+++ b/src/main/java/freemarker/core/NoAutoEscBlock.java
@@ -33,10 +33,8 @@ final class NoAutoEscBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
-        if (getNestedBlock() != null) {
-            env.visitByHiddingParent(getNestedBlock());
-        }
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
+        return new TemplateElementsToVisit(getNestedBlock(), true);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/NoEscapeBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/NoEscapeBlock.java b/src/main/java/freemarker/core/NoEscapeBlock.java
index f9d94bd..5a6b525 100644
--- a/src/main/java/freemarker/core/NoEscapeBlock.java
+++ b/src/main/java/freemarker/core/NoEscapeBlock.java
@@ -32,10 +32,8 @@ class NoEscapeBlock extends TemplateElement {
     }
     
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
-        if (getNestedBlock() != null) {
-            env.visit(getNestedBlock());
-        }
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
+        return new TemplateElementsToVisit(getNestedBlock(), false);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/NumericalOutput.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/NumericalOutput.java b/src/main/java/freemarker/core/NumericalOutput.java
index c9028c6..0fb67f7 100644
--- a/src/main/java/freemarker/core/NumericalOutput.java
+++ b/src/main/java/freemarker/core/NumericalOutput.java
@@ -59,7 +59,7 @@ final class NumericalOutput extends Interpolation {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         String s = calculateInterpolatedStringOrMarkup(env);
         Writer out = env.getOut();
         if (autoEscapeOutputFormat != null) {
@@ -67,6 +67,7 @@ final class NumericalOutput extends Interpolation {
         } else {
             out.write(s);
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/OutputFormatBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/OutputFormatBlock.java b/src/main/java/freemarker/core/OutputFormatBlock.java
index 12afb93..63b0c62 100644
--- a/src/main/java/freemarker/core/OutputFormatBlock.java
+++ b/src/main/java/freemarker/core/OutputFormatBlock.java
@@ -36,10 +36,8 @@ final class OutputFormatBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
-        if (getNestedBlock() != null) {
-            env.visitByHiddingParent(getNestedBlock());
-        }
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
+        return new TemplateElementsToVisit(getNestedBlock(), true);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/PropertySetting.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/PropertySetting.java b/src/main/java/freemarker/core/PropertySetting.java
index 7c9da68..8e4c23f 100644
--- a/src/main/java/freemarker/core/PropertySetting.java
+++ b/src/main/java/freemarker/core/PropertySetting.java
@@ -110,7 +110,7 @@ final class PropertySetting extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException {
         TemplateModel mval = value.eval(env);
         String strval;
         if (mval instanceof TemplateScalarModel) {
@@ -123,6 +123,7 @@ final class PropertySetting extends TemplateElement {
             strval = value.evalAndCoerceToStringOrUnsupportedMarkup(env);
         }
         env.setSetting(key, strval);
+        return null;
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/RecoveryBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/RecoveryBlock.java b/src/main/java/freemarker/core/RecoveryBlock.java
index 3e44468..69ae202 100644
--- a/src/main/java/freemarker/core/RecoveryBlock.java
+++ b/src/main/java/freemarker/core/RecoveryBlock.java
@@ -30,10 +30,8 @@ final class RecoveryBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
-        if (getNestedBlock() != null) {
-            env.visitByHiddingParent(getNestedBlock());
-        }
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
+        return new TemplateElementsToVisit(getNestedBlock(), true);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/RecurseNode.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/RecurseNode.java b/src/main/java/freemarker/core/RecurseNode.java
index 456727b..3b9afed 100644
--- a/src/main/java/freemarker/core/RecurseNode.java
+++ b/src/main/java/freemarker/core/RecurseNode.java
@@ -43,7 +43,7 @@ final class RecurseNode extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws IOException, TemplateException {
+    TemplateElementsToVisit accept(Environment env) throws IOException, TemplateException {
         TemplateModel node = targetNode == null ? null : targetNode.eval(env);
         if (node != null && !(node instanceof TemplateNodeModel)) {
             throw new NonNodeException(targetNode, node, "node", env);
@@ -71,6 +71,7 @@ final class RecurseNode extends TemplateElement {
         }
         
         env.recurse((TemplateNodeModel) node, (TemplateSequenceModel) nss);
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/ReturnInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/ReturnInstruction.java b/src/main/java/freemarker/core/ReturnInstruction.java
index b3d0574..d2d2985 100644
--- a/src/main/java/freemarker/core/ReturnInstruction.java
+++ b/src/main/java/freemarker/core/ReturnInstruction.java
@@ -33,7 +33,7 @@ public final class ReturnInstruction extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException {
         if (exp != null) {
             env.setLastReturnValue(exp.eval(env));
         }
@@ -45,6 +45,7 @@ public final class ReturnInstruction extends TemplateElement {
             // Here also, we need to jump out using an exception.
             throw Return.INSTANCE;
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/Sep.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Sep.java b/src/main/java/freemarker/core/Sep.java
index 7550656..2dec2d6 100644
--- a/src/main/java/freemarker/core/Sep.java
+++ b/src/main/java/freemarker/core/Sep.java
@@ -33,7 +33,7 @@ class Sep extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         final IterationContext iterCtx = IteratorBlock.findEnclosingIterationContext(env, null);
         if (iterCtx == null) {
             // The parser should prevent this situation
@@ -42,8 +42,9 @@ class Sep extends TemplateElement {
         }
         
         if (iterCtx.hasNext()) {
-            env.visitByHiddingParent(getNestedBlock());
+            return new TemplateElementsToVisit(getNestedBlock(), true);
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/StopInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/StopInstruction.java b/src/main/java/freemarker/core/StopInstruction.java
index c6a7526..231725c 100644
--- a/src/main/java/freemarker/core/StopInstruction.java
+++ b/src/main/java/freemarker/core/StopInstruction.java
@@ -33,7 +33,7 @@ final class StopInstruction extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException {
         if (exp == null) {
             throw new StopException(env);
         }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/SwitchBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/SwitchBlock.java b/src/main/java/freemarker/core/SwitchBlock.java
index 284aa02..e416b8d 100644
--- a/src/main/java/freemarker/core/SwitchBlock.java
+++ b/src/main/java/freemarker/core/SwitchBlock.java
@@ -50,7 +50,7 @@ final class SwitchBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) 
+    TemplateElementsToVisit accept(Environment env)
         throws TemplateException, IOException {
         boolean processedCase = false;
         int ln = getRegulatedChildCount();
@@ -80,6 +80,7 @@ final class SwitchBlock extends TemplateElement {
                 env.visitByHiddingParent(defaultCase);
             }
         } catch (BreakInstruction.Break br) {}
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/TemplateElement.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TemplateElement.java b/src/main/java/freemarker/core/TemplateElement.java
index 07407f3..0f5be0f 100644
--- a/src/main/java/freemarker/core/TemplateElement.java
+++ b/src/main/java/freemarker/core/TemplateElement.java
@@ -22,12 +22,15 @@ package freemarker.core;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.List;
 
 import freemarker.template.SimpleSequence;
 import freemarker.template.TemplateException;
 import freemarker.template.TemplateNodeModel;
 import freemarker.template.TemplateSequenceModel;
 
+import static java.util.Arrays.asList;
+
 /**
  * <b>Internal API - subject to change:</b> Represent directive call, interpolation, text block, or other such
  * non-expression node in the parsed template. Some information that can be found here can be accessed through the
@@ -74,7 +77,7 @@ abstract public class TemplateElement extends TemplateObject {
      *
      * @param env The runtime environment
      */
-    abstract void accept(Environment env) throws TemplateException, IOException;
+    abstract TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException;
 
     /**
      * One-line description of the element, that contain all the information that is used in
@@ -316,6 +319,10 @@ abstract public class TemplateElement extends TemplateObject {
     final TemplateElement getRegulatedChild(int index) {
         return regulatedChildBuffer[index];
     }
+
+    final List<TemplateElement> getRegulatedChildren(){
+        return asList(regulatedChildBuffer);
+    }
     
     final int getIndex() {
         return index;

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/TemplateElementsToVisit.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TemplateElementsToVisit.java b/src/main/java/freemarker/core/TemplateElementsToVisit.java
new file mode 100644
index 0000000..97aa6ea
--- /dev/null
+++ b/src/main/java/freemarker/core/TemplateElementsToVisit.java
@@ -0,0 +1,31 @@
+package freemarker.core;
+
+import java.util.Collection;
+import java.util.Collections;
+
+class TemplateElementsToVisit {
+
+  private final Collection<TemplateElement> templateElements;
+  private final boolean hideInParent;
+
+  TemplateElementsToVisit(Collection<TemplateElement> templateElements, boolean hideInParent) {
+    this.templateElements = null != templateElements ? templateElements : Collections.<TemplateElement>emptyList();
+    this.hideInParent = hideInParent;
+  }
+
+  public TemplateElementsToVisit(Collection<TemplateElement> templateElements) {
+    this(templateElements, false);
+  }
+
+  public TemplateElementsToVisit(TemplateElement nestedBlock, boolean hideInParent) {
+    this(Collections.singleton(nestedBlock), hideInParent);
+  }
+
+  Collection<TemplateElement> getTemplateElements() {
+    return templateElements;
+  }
+
+  boolean isHideInParent() {
+    return hideInParent;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/TextBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TextBlock.java b/src/main/java/freemarker/core/TextBlock.java
index 688ddae..c8a6d5c 100644
--- a/src/main/java/freemarker/core/TextBlock.java
+++ b/src/main/java/freemarker/core/TextBlock.java
@@ -58,9 +58,10 @@ public final class TextBlock extends TemplateElement {
      * Simply outputs the text.
      */
     @Override
-    public void accept(Environment env) 
+    public TemplateElementsToVisit accept(Environment env)
     throws IOException {
         env.getOut().write(text);
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java b/src/main/java/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
index e17494d..4e0b152 100644
--- a/src/main/java/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
+++ b/src/main/java/freemarker/core/ThreadInterruptionSupportTemplatePostProcessor.java
@@ -110,12 +110,13 @@ class ThreadInterruptionSupportTemplatePostProcessor extends TemplatePostProcess
         }
 
         @Override
-        void accept(Environment env) throws TemplateException, IOException {
+        TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
             // As the API doesn't allow throwing InterruptedException here (nor anywhere else, most importantly,
             // Template.process can't throw it), we must not clear the "interrupted" flag of the thread.
             if (Thread.currentThread().isInterrupted()) {
                 throw new TemplateProcessingThreadInterruptedException();
             }
+            return null;
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/TransformBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TransformBlock.java b/src/main/java/freemarker/core/TransformBlock.java
index f7a1db9..9f07e85 100644
--- a/src/main/java/freemarker/core/TransformBlock.java
+++ b/src/main/java/freemarker/core/TransformBlock.java
@@ -55,7 +55,7 @@ final class TransformBlock extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) 
+    TemplateElementsToVisit accept(Environment env)
     throws TemplateException, IOException {
         TemplateTransformModel ttm = env.getTransform(transformExpression);
         if (ttm != null) {
@@ -79,6 +79,7 @@ final class TransformBlock extends TemplateElement {
                     transformExpression, tm,
                     "transform", new Class[] { TemplateTransformModel.class }, env);
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/TrimInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TrimInstruction.java b/src/main/java/freemarker/core/TrimInstruction.java
index 053c5a0..31a6d78 100644
--- a/src/main/java/freemarker/core/TrimInstruction.java
+++ b/src/main/java/freemarker/core/TrimInstruction.java
@@ -38,8 +38,9 @@ final class TrimInstruction extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) {
+    TemplateElementsToVisit accept(Environment env) {
         // This instruction does nothing at render-time, only parse-time.
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/UnifiedCall.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/UnifiedCall.java b/src/main/java/freemarker/core/UnifiedCall.java
index 825b111..2cfd481 100644
--- a/src/main/java/freemarker/core/UnifiedCall.java
+++ b/src/main/java/freemarker/core/UnifiedCall.java
@@ -72,9 +72,9 @@ final class UnifiedCall extends TemplateElement implements DirectiveCallPlace {
     }
 
     @Override
-    void accept(Environment env) throws TemplateException, IOException {
+    TemplateElementsToVisit accept(Environment env) throws TemplateException, IOException {
         TemplateModel tm = nameExp.eval(env);
-        if (tm == Macro.DO_NOTHING_MACRO) return; // shortcut here.
+        if (tm == Macro.DO_NOTHING_MACRO) return null; // shortcut here.
         if (tm instanceof Macro) {
             Macro macro = (Macro) tm;
             if (macro.isFunction() && !legacySyntax) {
@@ -112,6 +112,7 @@ final class UnifiedCall extends TemplateElement implements DirectiveCallPlace {
                 throw new NonUserDefinedDirectiveLikeException(nameExp, tm, env);
             }
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/699d4426/src/main/java/freemarker/core/VisitNode.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/VisitNode.java b/src/main/java/freemarker/core/VisitNode.java
index b35e3f8..7bb8375 100644
--- a/src/main/java/freemarker/core/VisitNode.java
+++ b/src/main/java/freemarker/core/VisitNode.java
@@ -42,7 +42,7 @@ final class VisitNode extends TemplateElement {
     }
 
     @Override
-    void accept(Environment env) throws IOException, TemplateException {
+    TemplateElementsToVisit accept(Environment env) throws IOException, TemplateException {
         TemplateModel node = targetNode.eval(env);
         if (!(node instanceof TemplateNodeModel)) {
             throw new NonNodeException(targetNode, node, env);
@@ -69,6 +69,7 @@ final class VisitNode extends TemplateElement {
             }
         }
         env.invokeNodeHandlerFor((TemplateNodeModel) node, (TemplateSequenceModel) nss);
+        return null;
     }
 
     @Override


Mime
View raw message