コード例 #1
0
        public void shouldReturnTagsWithTexts()
        {
            loadInParser("assignment.jade");
            block = (BlockNode)root;
            LinkedList <Node> nodes = block.getNodes();

            Assert.AreEqual(2, nodes.Count);

            AssigmentNode assignment = (AssigmentNode)block.getNodes().ElementAt(0);

            Assert.AreEqual("hello", assignment.getName());
            Assert.AreEqual("\"world\"", assignment.getValue());

            TagNode tag = (TagNode)block.getNodes().ElementAt(1);

            Assert.IsNotNull(tag);
        }
コード例 #2
0
ファイル: JadeParser.cs プロジェクト: mirannda/Jade4Net
        private Node parseBlock()
        {
            Token  token      = expect(typeof(Block));
            Block  blockToken = (Block)token;
            String mode       = blockToken.getMode();
            String name       = blockToken.getValue().Trim();

            Node blockNode;

            if (peek() is Indent)
            {
                blockNode = block();
            }
            else
            {
                blockNode = new BlockNode();
                blockNode.setLineNumber(blockToken.getLineNumber());
                blockNode.setFileName(filename);
            }

            ((BlockNode)blockNode).setMode(mode);

            if (blocks.ContainsKey(name))
            {
                BlockNode prev = (BlockNode)blocks[name];
                if ("append".Equals(prev.getMode()))
                {
                    blockNode.getNodes().AppendRange(prev.getNodes());
                }
                if ("prepend".Equals(prev.getMode()))
                {
                    blockNode.getNodes().PrependRange(prev.getNodes());
                }
                if ("replace".Equals(prev.getMode()))
                {
                    blockNode = prev;
                }
            }

            blocks.Add(name, blockNode);
            return(blockNode);
        }
コード例 #3
0
ファイル: JadeParser.cs プロジェクト: mirannda/Jade4Net
 private Node blockExpansion()
 {
     if (peek() is Colon)
     {
         Token token = expect(typeof(Colon))
         ;
         Colon     colon     = (Colon)token;
         BlockNode blockNode = new BlockNode();
         blockNode.setLineNumber(colon.getLineNumber());
         blockNode.setFileName(filename);
         blockNode.getNodes().AddLast(parseExpr());
         return(blockNode);
     }
     return(block());
 }