Ejemplo n.º 1
0
        internal static string Open(
            string name,
            AttributeList attributes,
            TagOptions options)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return("");
            }

            options = TagOptions.UseOrCreate(options);

            // if we have a data-list of attributes, add to object
            if (attributes.Options == null)
            {
                attributes.Options = options.Attribute;
            }
            var attributeText = attributes?.ToString() ?? "";

            // ensure attributes have space in front
            if (!string.IsNullOrEmpty(attributeText) && attributeText[0] != ' ')
            {
                attributeText = " " + attributeText;
            }

            var selfClose = options.Close && options.SelfClose ? "/" : "";

            return($"<{name}{attributeText}{selfClose}>");
        }