ArrayList<TagNode> conditionals = new ArrayList<TagNode>();
for (Fragment f : this) {
if (f instanceof TagNode) {
TagNode t = (TagNode) f;
ConditionalTagBehavior behavior = t.getConditionalBehavior();
if (behavior != null) {
conditionals.add(t);
}
}
}
if (conditionals.size() == 0) {
return;
}
ArrayList<ConditionalBlock> blocks = new ArrayList<ConditionalBlock>();
for (int i = 0; i < conditionals.size(); i++) {
ConditionalBlock currentBlock = null;
TagNode t = conditionals.get(i);
ConditionalTagBehavior behavior = t.getConditionalBehavior();
main:
do {
TagNode nextTag = getNextTag(t);
TagNode nextConditional = i + 1 < conditionals.size() ? conditionals.get(i + 1) : null;
if (currentBlock == null && behavior.getType() == FIRST
&& nextTag == nextConditional && nextTag != null
&& nextConditional.getConditionalBehavior().getType() != FIRST) {
currentBlock = new ConditionalBlock(t);
}
if (nextTag == null || nextConditional == null) {
break;
}
if (currentBlock == null && behavior.getType() != FIRST) {
throw new TemplateParsingException(behavior.getValidationError(), nextTag.getBeginLine(), nextTag.getBeginColumn());
}
if (nextTag == nextConditional) {
switch (nextTag.getConditionalBehavior().getType()) {
case FIRST: