package com.hubspot.jinjava.lib.tag.eager;

import com.hubspot.jinjava.interpret.InterpretException;
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
import com.hubspot.jinjava.lib.tag.FlexibleTag;
import com.hubspot.jinjava.lib.tag.Tag;
import com.hubspot.jinjava.tree.TagNode;
import com.hubspot.jinjava.tree.parse.TagToken;
import com.hubspot.jinjava.util.EagerExpressionResolver.EagerExpressionResult;
import org.apache.commons.lang3.StringUtils;

public class EagerStateChangingTag<T extends Tag> extends EagerTagDecorator<T> {

  public EagerStateChangingTag(T tag) {
    super(tag);
  }

  @Override
  public String interpret(TagNode tagNode, JinjavaInterpreter interpreter) {
    return eagerInterpret(tagNode, interpreter, null);
  }

  @Override
  public String eagerInterpret(
    TagNode tagNode,
    JinjavaInterpreter interpreter,
    InterpretException e
  ) {
    StringBuilder result = new StringBuilder(
      getEagerImage(buildToken(tagNode, e, interpreter.getLineNumber()), interpreter)
    );

    // Currently always false
    if (!tagNode.getChildren().isEmpty()) {
      result.append(
        executeInChildContext(
          eagerInterpreter ->
            EagerExpressionResult.fromString(renderChildren(tagNode, eagerInterpreter)),
          interpreter,
          false,
          false,
          true
        )
      );
    }

    // Currently always false
    if (
      StringUtils.isNotBlank(tagNode.getEndName()) &&
      (
        !(getTag() instanceof FlexibleTag) ||
        ((FlexibleTag) getTag()).hasEndTag((TagToken) tagNode.getMaster())
      )
    ) {
      result.append(reconstructEnd(tagNode));
    }

    return result.toString();
  }
}

@@ -1021,38 +1021,8 @@
 );%0A%0A
-    // Currently always false%0A
     
@@ -1334,38 +1334,8 @@
  %7D%0A%0A
-    // Currently always false%0A
     

Remove outdated comments