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

            ParseNode(result, hamlFile);

            return result;
        }
Esempio 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));
        }
Esempio 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;
        }
Esempio 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);
                    }
                }
            }
        }