private Node parseInclude() { Token token = expect(typeof(Include)); Include includeToken = (Include)token; String templateName = includeToken.getValue().Trim(); String extension = Path.GetExtension(templateName); if (!"".Equals(extension) && !"jade".Equals(extension)) { FilterNode node = new FilterNode(); node.setLineNumber(_jadeLexer.getLineno()); node.setFileName(filename); node.setValue(extension); try { TextReader reader = templateLoader.getReader(resolvePath(templateName)); Node textNode = new TextNode(); textNode.setFileName(filename); textNode.setLineNumber(_jadeLexer.getLineno()); textNode.setValue(reader.ReadToEnd()); node.setTextBlock(textNode); } catch (IOException e) { throw new JadeParserException(filename, _jadeLexer.getLineno(), templateLoader, "the included file [" + templateName + "] could not be opened\n" + e.Message); } return(node); } JadeParser jadeParser = createParser(templateName); jadeParser.setBlocks(blocks); contexts.AddLast(jadeParser); Node ast = jadeParser.parse(); contexts.RemoveLast(); if (peek() is Indent && ast is BlockNode) { ((BlockNode)ast).getIncludeBlock().push(block()); } return(ast); }
private Node parseExtends() { Token token = expect(typeof(ExtendsToken)) ; ExtendsToken extendsToken = (ExtendsToken)token; String templateName = extendsToken.getValue().Trim(); JadeParser jadeParser = createParser(templateName); jadeParser.setBlocks(blocks); jadeParser.setContexts(contexts); extending = jadeParser; LiteralNode node = new LiteralNode(); node.setValue(""); return(node); }