示例#1
0
        /// <summary>
        /// Renders the begin tag without end char.
        /// </summary>
        private void RenderBeginTagCore(string name)
        {
            writer.Write("<");
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new InvalidOperationException("HtmlWriter cannot render tag, because tag name is empty.");
            }
            AssertIsValidHtmlName(name);
            writer.Write(name);

            foreach (DictionaryEntry attr in dataBindAttributes)
            {
                AddAttribute("data-bind", attr.Key + ": " + ConvertHtmlAttributeValue(attr.Value), true, ", ");
            }
            dataBindAttributes.Clear();

            if (attributes.Count > 0)
            {
                foreach (DictionaryEntry attr in attributes)
                {
                    var attributeName  = (string)attr.Key;
                    var attributeValue = ConvertHtmlAttributeValue(attr.Value);

                    // allow to use the attribute transformer
                    var pair = new HtmlTagAttributePair()
                    {
                        TagName = name, AttributeName = attributeName
                    };
                    HtmlAttributeTransformConfiguration transformConfiguration;
                    if (requestContext.Configuration.Markup.HtmlAttributeTransforms.TryGetValue(pair, out transformConfiguration))
                    {
                        // use the transformer
                        var transformer = transformConfiguration.GetInstance();
                        transformer.RenderHtmlAttribute(this, requestContext, attributeName, attributeValue);
                    }
                    else
                    {
                        WriteHtmlAttribute(attributeName, attributeValue);
                    }
                }
            }

            attributes.Clear();
        }
示例#2
0
        /// <summary>
        /// Renders the begin tag without end char.
        /// </summary>
        private void RenderBeginTagCore(string name)
        {
            writer.Write("<");
            writer.Write(name);

            foreach (DictionaryEntry attr in dataBindAttributes)
            {
                AddAttribute("data-bind", attr.Key + ": " + ConvertHtmlAttributeValue(attr.Value), true, ", ");
            }
            dataBindAttributes.Clear();

            if (attributes.Count > 0)
            {
                foreach (DictionaryEntry attr in attributes)
                {
                    var attributeName  = (string)attr.Key;
                    var attributeValue = ConvertHtmlAttributeValue(attr.Value);

                    // allow to use the attribute transformer
                    var pair = new HtmlTagAttributePair()
                    {
                        TagName = name, AttributeName = attributeName
                    };
                    HtmlAttributeTransformConfiguration transformConfiguration;
                    if (requestContext.Configuration.Markup.HtmlAttributeTransforms.TryGetValue(pair, out transformConfiguration))
                    {
                        // use the transformer
                        var transformer = transformConfiguration.GetInstance();
                        transformer.RenderHtmlAttribute(this, requestContext, attributeName, attributeValue);
                    }
                    else
                    {
                        WriteHtmlAttribute(attributeName, attributeValue);
                    }
                }
            }

            attributes.Clear();
        }