use of jetbrick.template.parser.grammer.JetTemplateParser.Elseif_directiveContext in project jetbrick-template-1x by subchen.
the class JetTemplateCodeVisitor method visitIf_directive.
@Override
public Code visitIf_directive(If_directiveContext ctx) {
BlockCode code = scopeCode.createBlockCode(16);
SegmentCode expr_code = (SegmentCode) ctx.expression().accept(this);
code.addLine("if (" + get_if_expression_source(expr_code) + ") { // line: " + ctx.getStart().getLine());
scopeCode = scopeCode.push();
code.addChild(ctx.block().accept(this));
scopeCode = scopeCode.pop();
code.addLine("}");
// elseif ...
List<Elseif_directiveContext> elseif_directive_list = ctx.elseif_directive();
for (Elseif_directiveContext elseif_directive : elseif_directive_list) {
code.addChild(elseif_directive.accept(this));
}
// else ...
Else_directiveContext else_directive = ctx.else_directive();
if (else_directive != null) {
code.addChild(else_directive.accept(this));
}
return code;
}
Aggregations