Ejemplo n.º 1
0
        public HamlDocument ParseHamlFile(HamlFile hamlFile)
        {
            var result = new HamlDocument();

            ParseNode(result, hamlFile);

            return result;
        }
Ejemplo n.º 2
0
        public void ParseHamlFile_UnknownRuleType_ThrowsUnknownRuleException()
        {
            var fakeLine = new HamlLineFake("") {HamlRule = HamlRuleEnum.Unknown};

            var file = new HamlFile();
            file.AddLine(fakeLine);
            Assert.Throws<HamlUnknownRuleException>(() => _parser.ParseHamlFile(file));
        }
Ejemplo n.º 3
0
        public HamlFile Read(TextReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            var result = new HamlFile();

            while (_eof == false)
            {
                string currentLine = ReadLine(reader);
                //if ((!string.IsNullOrEmpty(currentLine)) || (_eof == false))
                result.AddLine(new HamlLine(currentLine));
            }

            return result;
        }
Ejemplo n.º 4
0
        private void ParseNode(HamlNode node, HamlFile hamlFile)
        {
            node.IsMultiLine = true;
            while ((!hamlFile.EndOfFile) && (hamlFile.CurrentLine.IndentCount > node.IndentCount))
            {
                HamlLine nodeLine = hamlFile.CurrentLine;
                HamlNode childNode = GetHamlNode(nodeLine);
                node.Add(childNode);

                hamlFile.MoveNext();
                if (hamlFile.EndOfFile == false)
                {
                    childNode.Add(new HamlNodeText(new HamlLine("\n")));
                    if (hamlFile.CurrentLine.IndentCount > nodeLine.IndentCount)
                    {
                        ParseNode(childNode, hamlFile);
                    }
                }
            }
        }