private Node parseTextBlock() { BlockNode blockNode = new BlockNode(); blockNode.setLineNumber(line()); blockNode.setFileName(filename); Token body = peek(); if(!(body instanceof PipelessText)){ return null; } this.advance(); ArrayList<String> values = body.getValues(); Node[] textNodes = {}; for (String value : values) { textNodes = ArrayUtils.addAll(textNodes,parseInlineTagsInText(value)); } blockNode.setNodes(new LinkedList<Node>(Arrays.asList(textNodes))); return blockNode; }
private Node parseCssClassOrId() { Token tok = advance(); Tag div = new Tag("div", line()); lexer.defer(div); lexer.defer(tok); return parseExpr(); } private Node parseBlock() {
private Node[] parseInlineTagsInText(String str) { int line = this.line(); Matcher matcher = Pattern.compile("(\\\\)?#\\[((?:.|\\n)*)$").matcher(str); TextNode text = new TextNode();
blockNode.setLineNumber(line());
FilterNode node = new FilterNode(); node.setValue(includeToken.getFilter()); node.setLineNumber(line()); node.setFileName(filename); TextNode text = new TextNode();
private Node parseASTFilter() { Token token = expect(Filter.class); Filter filterToken = (Filter) token; AttributeList attr = (AttributeList) accept(AttributeList.class); token = expect(Colon.class); FilterNode node = new FilterNode(); node.setValue(filterToken.getValue()); node.setBlock(block()); node.setLineNumber(line()); node.setFileName(filename); node.setAttributes(convertToNodeAttributes(attr)); 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; } /**
private Node parseFilter() { Token token = expect(Filter.class); Filter filterToken = (Filter) token; AttributeList attr = (AttributeList) accept(AttributeList.class); lexer.setPipeless(true); Node tNode = parseTextBlock(); lexer.setPipeless(false); FilterNode node = new FilterNode(); node.setValue(filterToken.getValue()); node.setLineNumber(line()); node.setFileName(filename); if(tNode!=null) node.setTextBlock(tNode); else{ node.setTextBlock(new BlockNode()); } if (attr != null) { node.setAttributes(convertToNodeAttributes(attr)); } return node; }
} else if (incomingToken instanceof AttributeList) { if (seenAttrs) { throw new JadeParserException(filename,line(),templateLoader,this.filename + ", line " + this.peek().getLineNumber() + ":\nYou should not have jade tags with multiple attributes.");
private Node parseTextBlock() { BlockNode blockNode = new BlockNode(); blockNode.setLineNumber(line()); blockNode.setFileName(filename); Token body = peek(); if(!(body instanceof PipelessText)){ return null; } this.advance(); ArrayList<String> values = body.getValues(); Node[] textNodes = {}; for (String value : values) { textNodes = ArrayUtils.addAll(textNodes,parseInlineTagsInText(value)); } blockNode.setNodes(new LinkedList<Node>(Arrays.asList(textNodes))); return blockNode; }
private Node parseCssClassOrId() { Token tok = advance(); Tag div = new Tag("div", line()); lexer.defer(div); lexer.defer(tok); return parseExpr(); } private Node parseBlock() {
private Node[] parseInlineTagsInText(String str) { int line = this.line(); Matcher matcher = Pattern.compile("(\\\\)?#\\[((?:.|\\n)*)$").matcher(str); TextNode text = new TextNode();
blockNode.setLineNumber(line());
FilterNode node = new FilterNode(); node.setValue(includeToken.getFilter()); node.setLineNumber(line()); node.setFileName(filename); TextNode text = new TextNode();
private Node parseASTFilter() { Token token = expect(Filter.class); Filter filterToken = (Filter) token; AttributeList attr = (AttributeList) accept(AttributeList.class); token = expect(Colon.class); FilterNode node = new FilterNode(); node.setValue(filterToken.getValue()); node.setBlock(block()); node.setLineNumber(line()); node.setFileName(filename); node.setAttributes(convertToNodeAttributes(attr)); 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; } /**
private Node parseFilter() { Token token = expect(Filter.class); Filter filterToken = (Filter) token; AttributeList attr = (AttributeList) accept(AttributeList.class); lexer.setPipeless(true); Node tNode = parseTextBlock(); lexer.setPipeless(false); FilterNode node = new FilterNode(); node.setValue(filterToken.getValue()); node.setLineNumber(line()); node.setFileName(filename); if(tNode!=null) node.setTextBlock(tNode); else{ node.setTextBlock(new BlockNode()); } if (attr != null) { node.setAttributes(convertToNodeAttributes(attr)); } return node; }
} else if (incomingToken instanceof AttributeList) { if (seenAttrs) { throw new JadeParserException(filename,line(),templateLoader,this.filename + ", line " + this.peek().getLineNumber() + ":\nYou should not have jade tags with multiple attributes.");