예제 #1
0
        /// <summary>
        /// Renders the style property
        /// </summary>
        /// <param name="tag"></param>
        private void WriteAttributes(HtmlTag tag)
        {
            foreach (KeyValuePair <string, object> attribute in tag.FilteredAttributes)
            {
                if (attribute.Value is HtmlTag)
                {
                    // HTML doesn't allow tags in attributes unlike code markup
                    continue;
                }
                string value = attribute.Value as string;

                this.writer.Write(' ');
                if (String.IsNullOrEmpty(value))
                {
                    HtmlDistiller.HtmlAttributeEncode(attribute.Key, this.writer);
                }
                else if (String.IsNullOrEmpty(attribute.Key))
                {
                    HtmlDistiller.HtmlAttributeEncode(value, this.writer);
                }
                else
                {
                    HtmlDistiller.HtmlAttributeEncode(attribute.Key, this.writer);
                    this.writer.Write("=\"");
                    HtmlDistiller.HtmlAttributeEncode(value, this.writer);
                    this.writer.Write("\"");
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Renders the style property
        /// </summary>
        /// <param name="output"></param>
        private void WriteStyles(HtmlTag tag)
        {
            this.writer.Write(" style=\"");

            foreach (KeyValuePair <string, string> style in tag.FilteredStyles)
            {
                HtmlDistiller.HtmlAttributeEncode(style.Key, this.writer);
                this.writer.Write(':');
                HtmlDistiller.HtmlAttributeEncode(style.Value, this.writer);
                this.writer.Write(';');
            }

            this.writer.Write('\"');
        }