@Override
void endTag() {
String tagName = parser.getToken().trim();
if (tagsStack.isEmpty()) {
throw new TemplateCompilationException(template, parser.getLine(), "#{/" + tagName + "} is not opened.");
}
Tag tag = tagsStack.pop();
String lastInStack = tag.name;
if (tagName.equals("")) {
tagName = lastInStack;
}
if (!lastInStack.equals(tagName)) {
throw new TemplateCompilationException(template, tag.startLine, "#{" + tag.name + "} is not closed.");
}
if (tag.name.equals("doBody")) {
print("if(_body || attrs" + tagIndex + "['body']) {");
print("def toExecute = attrs" + tagIndex + "['body'] ?: _body; toUnset = []; if(attrs" + tagIndex + "['vars']) {");
print("attrs" + tagIndex + "['vars'].each() {");