Esempio n. 1
0
        private static void ParseAndRenderAttributes(TemplateClassBuilder builder, Match tagMatch)
        {
            var idAndClasses   = tagMatch.Groups[2].Value;
            var attributesHash = tagMatch.Groups[4].Value.Trim();

            var match = _idClassesRegex.Match(idAndClasses);

            var classes = new List <string>();

            foreach (Capture capture in match.Groups[2].Captures)
            {
                classes.Add(capture.Value);
            }

            if (classes.Count > 0)
            {
                attributesHash = PrependAttribute(attributesHash, Class, string.Join(" ", classes.ToArray()));
            }

            string id = null;

            foreach (Capture capture in match.Groups[1].Captures)
            {
                id = capture.Value;
                break;
            }

            if (!string.IsNullOrEmpty(id))
            {
                attributesHash = PrependAttribute(attributesHash, Id, id);
            }

            if (string.IsNullOrEmpty(attributesHash))
            {
                return;
            }

            var attributeParser = new AttributeParser(attributesHash);

            attributeParser.Parse();
            foreach (var attribute in attributeParser.Attributes)
            {
                if (attribute.Type == ParsedAttributeType.String)
                {
                    var expressionStringParser = new ExpressionStringParser(attribute.Value);

                    expressionStringParser.Parse();

                    builder.AppendAttributeTokens(attribute.Schema, attribute.Name, expressionStringParser.ExpressionStringTokens);
                }
                else
                {
                    var token = new ExpressionStringToken(attribute.Value, true);

                    builder.AppendAttributeTokens(attribute.Schema, attribute.Name, new[] { token });
                }
            }
        }
Esempio n. 2
0
        private static void ParseAndRenderAttributes(TemplateClassBuilder builder, Match tagMatch)
        {
            var idAndClasses = tagMatch.Groups[2].Value;
            var attributesHash = tagMatch.Groups[4].Value.Trim();

            var match = _idClassesRegex.Match(idAndClasses);

            var classes = new List<string>();

            foreach (Capture capture in match.Groups[2].Captures)
            {
                classes.Add(capture.Value);
            }

            if (classes.Count > 0)
            {
                attributesHash = PrependAttribute(attributesHash, Class, string.Join(" ", classes.ToArray()));
            }

            string id = null;
            foreach (Capture capture in match.Groups[1].Captures)
            {
                id = capture.Value;
                break;
            }

            if (!string.IsNullOrEmpty(id))
            {
                attributesHash = PrependAttribute(attributesHash, Id, id);
            }

            if (string.IsNullOrEmpty(attributesHash))
            {
                return;
            }

            var attributeParser = new AttributeParser(attributesHash);
            attributeParser.Parse();
            foreach (var attribute in attributeParser.Attributes)
            {
                if (attribute.Type == ParsedAttributeType.String)
                {
                    var expressionStringParser = new ExpressionStringParser(attribute.Value);

                    expressionStringParser.Parse();

                    builder.AppendAttributeTokens(attribute.Schema, attribute.Name, expressionStringParser.ExpressionStringTokens);
                }
                else
                {
                    var token = new ExpressionStringToken(attribute.Value, true);

                    builder.AppendAttributeTokens(attribute.Schema, attribute.Name, new[] { token });
                }
            }
        }