@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { try { boolean skip = false; for (Node when : block.getNodes()) { if (skip || "default".equals(when.getValue()) || checkCondition(model, when,template.getExpressionHandler())) { skip = false; if(when.getBlock()!=null) { when.execute(writer, model, template); break; }else { skip = true; } } } } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } }
private Node parseCase() { String val = expect(CaseToken.class).getValue(); Node node = new CaseNode(); node.setValue(val); node.setLineNumber(line()); Node block = new BlockNode(); block.setLineNumber(line()); block.setFileName(filename); expect(Indent.class); while (!(peek() instanceof Outdent)) { if (peek() instanceof Comment) { advance(); } else if (peek() instanceof Newline) { advance(); } else if (peek() instanceof When) { block.push(parseWhen()); } else if (peek() instanceof Default) { block.push(parseDefault()); } else { throw new JadeParserException(filename,lexer.getLineno(),templateLoader,"Unexpected token \"" + this.peek() + "\", expected \"when\", \"default\" or \"newline\""); } } expect(Outdent.class); node.setBlock(block); return node; } /**
private Node parseCase() { String val = expect(CaseToken.class).getValue(); Node node = new CaseNode(); node.setValue(val); node.setLineNumber(line()); Node block = new BlockNode(); block.setLineNumber(line()); block.setFileName(filename); expect(Indent.class); while (!(peek() instanceof Outdent)) { if (peek() instanceof Comment) { advance(); } else if (peek() instanceof Newline) { advance(); } else if (peek() instanceof When) { block.push(parseWhen()); } else if (peek() instanceof Default) { block.push(parseDefault()); } else { throw new JadeParserException(filename,lexer.getLineno(),templateLoader,"Unexpected token \"" + this.peek() + "\", expected \"when\", \"default\" or \"newline\""); } } expect(Outdent.class); node.setBlock(block); return node; } /**
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { try { boolean skip = false; for (Node when : block.getNodes()) { if (skip || "default".equals(when.getValue()) || checkCondition(model, when,template.getExpressionHandler())) { skip = false; if(when.getBlock()!=null) { when.execute(writer, model, template); break; }else { skip = true; } } } } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } }