public void Visit(DothtmlAttributeNode attribute)
 {
     ResolveFromParent(attribute);
 }
예제 #2
0
 public void Visit(DothtmlAttributeNode attribute)
 {
     LastFoundNode = attribute;
 }
예제 #3
0
        /// <summary>
        /// Reads the attribute.
        /// </summary>
        private DothtmlAttributeNode ReadAttribute()
        {
            var startIndex = CurrentIndex;
            var attribute  = new DothtmlAttributeNode()
            {
                StartPosition = Peek().StartPosition
            };

            // attribute name
            DothtmlNameNode nameOrPrefix = ReadName(false, false, DothtmlTokenType.Text);

            if (Peek().Type == DothtmlTokenType.Colon)
            {
                attribute.PrefixSeparatorToken = Read();

                attribute.AttributePrefixNode = nameOrPrefix;

                attribute.AttributeNameNode = ReadName(false, false, DothtmlTokenType.Text);
            }
            else
            {
                attribute.AttributeNameNode = nameOrPrefix;
            }
            //spaces before separator belong to name
            attribute.AttributeNameNode.WhitespacesAfter = SkipWhiteSpace();


            if (Peek().Type == DothtmlTokenType.Equals)
            {
                attribute.ValueSeparatorToken = Read();

                attribute.ValueStartTokens = SkipWhiteSpace();
                // attribute value
                if (Peek().Type == DothtmlTokenType.SingleQuote || Peek().Type == DothtmlTokenType.DoubleQuote)
                {
                    var quote = Peek().Type;
                    attribute.ValueStartTokens.Add(Read());

                    var startingWhitespaces = SkipWhiteSpace();

                    if (Peek().Type == DothtmlTokenType.OpenBinding)
                    {
                        attribute.ValueNode = ReadBindingValue(false, true);
                    }
                    else
                    {
                        attribute.ValueNode = ReadTextValue(false, true, DothtmlTokenType.Text);
                    }
                    //we had to jump forward to decide
                    attribute.ValueNode.WhitespacesBefore = startingWhitespaces;

                    Assert(quote);
                    attribute.ValueEndTokens.Add(Read());
                }
                else
                {
                    attribute.ValueNode = ReadTextValue(false, false, DothtmlTokenType.Text);
                    //these are not part of any attribute or value
                    SkipWhiteSpace();
                }
                attribute.ValueEndTokens.AddRange(SkipWhiteSpace());
            }

            attribute.Tokens.AddRange(GetTokensFrom(startIndex));
            return(attribute);
        }
예제 #4
0
        /// <summary>
        /// Reads the attribute.
        /// </summary>
        private DothtmlAttributeNode ReadAttribute()
        {
            var startIndex = CurrentIndex;
            var attribute = new DothtmlAttributeNode() { StartPosition = Peek().StartPosition };

            // attribute name
            Assert(DothtmlTokenType.Text);
            attribute.AttributeNameToken = Read();
            attribute.AttributeName = attribute.AttributeNameToken.Text;
            if (Peek().Type == DothtmlTokenType.Colon)
            {
                Read();

                attribute.AttributePrefix = attribute.AttributeName;
                attribute.AttributePrefixToken = attribute.AttributeNameToken;
                Assert(DothtmlTokenType.Text);
                attribute.AttributeNameToken = Read();
                attribute.AttributeName = attribute.AttributeNameToken.Text;
            }
            SkipWhitespace();

            if (Peek().Type == DothtmlTokenType.Equals)
            {
                Read();
                SkipWhitespace();

                // attribute value
                if (Peek().Type == DothtmlTokenType.SingleQuote || Peek().Type == DothtmlTokenType.DoubleQuote)
                {
                    var quote = Peek().Type;
                    Read();

                    if (Peek().Type == DothtmlTokenType.OpenBinding)
                    {
                        attribute.Literal = ReadBinding();
                    }
                    else
                    {
                        Assert(DothtmlTokenType.Text);
                        attribute.Literal = new DothtmlLiteralNode() { Value = Peek().Text, Tokens = { Peek() }, StartPosition = Peek().StartPosition };
                        Read();
                    }

                    Assert(quote);
                    Read();
                }
                else
                {
                    Assert(DothtmlTokenType.Text);
                    attribute.Literal = new DothtmlLiteralNode() { Value = Peek().Text, Tokens = { Peek() }, StartPosition = Peek().StartPosition };
                    Read();
                }
                SkipWhitespace();
            }

            attribute.Tokens.AddRange(GetTokensFrom(startIndex));
            return attribute;
        }