Jade.Parser.JadeParser.parseInclude C# (CSharp) Method

parseInclude() private method

private parseInclude ( ) : Node
return Jade.Parser.Nodes.Node
        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;
        }