Example #1
0
 public static String GenerateHtmlAttributeString(HtmlAttributes attributeId)
 {
     switch (attributeId)
     {
         case HtmlAttributes.data_toggle:
             return "data-toggle";
         default:
             return attributeId.ToString();
     }
 }
        public void Renders_Correct_CSS_Class()
        {
            //Arrange
            var htmlAttributes = new HtmlAttributes();

            //Act
            Dictionary<string, object> attributes = htmlAttributes.CssClass("Hello World").Render();

            //Assert
            Assert.That(attributes["class"], Is.EqualTo("Hello World"));
        }
        public void Renders_Correct_Attribute()
        {
            //Arrange
            var htmlAttributes = new HtmlAttributes();

            //Act
            Dictionary<string, object> attributes = htmlAttributes.Attribute("data-url", "http://www.google.com").Render();

            //Assert
            Assert.That(attributes["data-url"], Is.EqualTo("http://www.google.com"));
        }
        public void Renders_Correct_Editable_Attribute()
        {
            //Arrange
            var htmlAttributes = new HtmlAttributes();

            //Act
            NameValueCollection attributes = htmlAttributes.Attribute("data-url", "http://www.google.com").RenderEditable();

            //Assert
            Assert.That(attributes["data-url"], Is.EqualTo("http://www.google.com"));
        }
        public void Renders_Correct_Editable_CSS_Class()
        {
            //Arrange
            var htmlAttributes = new HtmlAttributes();

            //Act
            NameValueCollection attributes = htmlAttributes.CssClass("Hello World").RenderEditable();

            //Assert
            Assert.That(attributes["class"], Is.EqualTo("Hello World"));
        }
Example #6
0
 public static HtmlBuilder Form(
     this HtmlBuilder hb,
     HtmlAttributes attributes,
     bool _using   = true,
     Action action = null)
 {
     return(_using
         ? hb.Append(
                tag: "form",
                id: null,
                css: null,
                attributes: attributes,
                action: action)
         : hb);
 }
Example #7
0
        public void When_object_constructor_overload_is_passed_a_HtmlAttributes_it_initializes_correctly()
        {
            var attributes =
                new HtmlAttributes(
                    new HtmlAttributes
            {
                { "class", "required" },
                { "style", "display:none" }
            });

            var html = attributes.ToString();

            html.Should()
            .Be("class=\"required\" style=\"display:none\"");
        }
Example #8
0
 public static IForm <TModel, TwitterBootstrapFormTemplate> BeginNglForm <TModel>(
     this HtmlHelper <TModel> htmlhelper,
     string action                 = "",
     FormMethod method             = FormMethod.Post,
     HtmlAttributes htmlAttributes = null,
     EncType?enctype               = null)
 {
     return(new NglForm <TModel, TwitterBootstrapFormTemplate>(
                htmlhelper,
                new TwitterBootstrapFormTemplate(),
                action,
                method,
                htmlAttributes,
                enctype));
 }
        public FileUploader(Localizer localizer)
        {
            HtmlAttributes.AppendCssClass("fileupload form-row align-items-center");
            HtmlAttributes.Add("data-accept", "gif|jpe?g|png");
            HtmlAttributes.Add("data-show-remove-after-upload", "false");
            IconCssClass = "fa fa-upload";
            ButtonStyle  = ButtonStyle.Secondary;

            if (localizer != null)
            {
                CancelText = localizer("Common.Fileuploader.Cancel");
                RemoveText = localizer("Common.Remove");
                UploadText = localizer("Common.Fileuploader.Upload");
            }
        }
Example #10
0
        public TextBoxBuilder <TModel, TProperty> Type(TextBoxType type)
        {
            _type = type;

            if (type == TextBoxType.Readonly)
            {
                HtmlAttributes["readonly"] = "";
            }
            else
            {
                HtmlAttributes.Remove("readonly");
            }

            return(this);
        }
Example #11
0
 public static HtmlBuilder Input(
     this HtmlBuilder hb,
     string id  = null,
     string css = null,
     HtmlAttributes attributes = null,
     bool _using = true)
 {
     return(_using
         ? hb.Append(
                tag: "input",
                closeLevel: 1,
                attributes: (attributes ?? new HtmlAttributes())
                .Id(id)
                .Class(css))
         : hb);
 }
Example #12
0
        protected Nancy.ViewEngines.Razor.IHtmlString GetInputHtml(TextInputType inputType)
        {
            ///TODO: GB fix this so it renders the password with the correct attributes:
            if (inputType == TextInputType.Password)
            {
                return(new NonEncodedHtmlString(string.Format(@"<input type=""password"" id="""" name="""" class="""" />")));
            }
            //return FieldGenerator.HtmlHelper.PasswordFor(FieldGenerator.FieldProperty, FieldConfiguration.HtmlAttributes);

            var attrs = new HtmlAttributes(FieldConfiguration.HtmlAttributes);

            attrs.Attr(type => inputType.ToString().ToLower());
            return(!string.IsNullOrEmpty(FieldConfiguration.FormatString)
                ? FieldGenerator.HtmlHelper.TextBoxFor(FieldGenerator.FieldProperty, FieldConfiguration.FormatString, attrs.ToDictionary())
                : FieldGenerator.HtmlHelper.TextBoxFor(FieldGenerator.FieldProperty, attrs.ToDictionary()));
        }
        public SelectBuilder <TModel, TProperty> Select2(string placeholder = null, bool allowClear = false)
        {
            CssClasses.Add("select2");

            if (!string.IsNullOrEmpty(placeholder))
            {
                HtmlAttributes.Add("data-placeholder", placeholder);
            }

            if (allowClear)
            {
                HtmlAttributes.Add("data-allowClear", "true");
            }

            return(this);
        }
Example #14
0
        public IDictionary <string, object> GetAttributes(object obj)
        {
            var model          = (TModel)obj;
            var htmlAttributes = HtmlAttributes.ToDictionary <KeyValuePair <string, string>, string, object>(htmlAttribute => htmlAttribute.Key, htmlAttribute => htmlAttribute.Value);

            foreach (var attribute in attributes)
            {
                var value = attribute.Value(model);
                if (value != null)
                {
                    htmlAttributes[attribute.Key] = Convert.ToString(value);
                }
            }

            return(htmlAttributes);
        }
Example #15
0
        private void UpdateFencedCodeLanguage(HtmlAttributes attributes, string originalLanguage, string updatedLanguage)
        {
            originalLanguage = Constants.FencedCodePrefix + originalLanguage;
            updatedLanguage  = Constants.FencedCodePrefix + updatedLanguage;

            var index = attributes.Classes?.IndexOf(originalLanguage);

            if (index.HasValue && index.Value != -1)
            {
                attributes.Classes[index.Value] = WebUtility.HtmlEncode(updatedLanguage);
            }
            else
            {
                attributes.AddClass(WebUtility.HtmlEncode(updatedLanguage));
            }
        }
Example #16
0
 private static HtmlAttributes Attributes(
     this HtmlAttributes attributes,
     SiteSettings ss,
     Aggregation aggregation,
     Column groupBy, string key)
 {
     return(groupBy != null
         ? attributes
            .Class("data" + (groupBy != null
                 ? " link"
                 : string.Empty))
            .DataSelector(Selector(ss, aggregation.GroupBy))
            .DataValue(DataValue(groupBy, key))
         : attributes
            .Class("data"));
 }
Example #17
0
 public static HtmlBuilder LabelValue(
     this HtmlBuilder hb,
     string label,
     string value,
     HtmlAttributes attributes)
 {
     return(hb.Span(attributes: attributes, action: () =>
     {
         if (label != string.Empty)
         {
             hb.Em(action: () => hb
                   .Text(label));
         }
         hb.Text(value);
     }));
 }
Example #18
0
        /// <summary>
        /// Creates the HTML for a form tag.
        /// </summary>
        /// <param name="action">The URL the form submits to</param>
        /// <param name="method">The HTTP method the form submits with</param>
        /// <param name="htmlAttributes">Any HTML attributes that should be applied to the form; specified as an anonymous object</param>
        /// <param name="encType">The encoding type the form uses</param>
        /// <returns>The HTML for the form</returns>
        public static IHtmlString BuildFormTag(string action, FormMethod method, HtmlAttributes htmlAttributes = null, EncType?encType = null)
        {
            var tagBuilder = new TagBuilder("form");

            if (htmlAttributes != null)
            {
                tagBuilder.MergeAttributes(htmlAttributes.Attributes);
            }
            tagBuilder.MergeAttribute("action", action);
            tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true);
            if (encType.HasValue)
            {
                tagBuilder.MergeAttribute("enctype", encType.Humanize());
            }
            return(new HtmlString(tagBuilder.ToString(TagRenderMode.StartTag)));
        }
        /// <summary>
        /// Create a new element.
        /// </summary>
        ///
        /// <param name="ns">
        /// The namespace.
        /// </param>
        /// <param name="name">
        /// The node name.
        /// </param>
        /// <param name="attributes">
        /// The attributes.
        /// </param>
        ///
        /// <returns>
        /// The new element.
        /// </returns>

        override protected DomObject CreateElement(string ns, string name, HtmlAttributes attributes)
        {
            // ns is not used
            DomElement rv = DomElement.Create(name);

            for (int i = 0; i < attributes.Length; i++)
            {
                string attributeName = AttributeName(attributes.GetLocalName(i), attributes.GetURI(i));
                rv.SetAttribute(attributeName, attributes.GetValue(i));
                //if (attributes.GetType(i) == "ID")
                //{
                //rv.setIdAttributeNS(null, attributes.GetLocalName(i), true); // FIXME
                //}
            }
            return(rv);
        }
Example #20
0
        public static string GetHtmlAttributeName(HtmlAttributes att)
        {
            switch (att)
            {
            case HtmlAttributes.img_alt_text:
                return("alt");

            case HtmlAttributes.bgcolor:
                return("bgcolor");

            case HtmlAttributes.colspan:
                return("colspan");

            case HtmlAttributes.height:
                return("height");

            case HtmlAttributes.href:
                return("href");

            case HtmlAttributes.rowspan:
                return("rowspan");

            case HtmlAttributes.src:
                return("src");

            case HtmlAttributes.style:
                return("style");

            case HtmlAttributes.style_class:
                return("class");

            case HtmlAttributes.target:
                return("target");

            case HtmlAttributes.width:
                return("width");

            case HtmlAttributes.border:
                return("border");

            case HtmlAttributes.cellspacing:
                return("cellspacing");

            default:
                throw new XhtmlException("GetHtmlAttributeName: unknown html- Attribute: " + att.ToString());
            }
        }
        public void Replace_attributes_with_empty_string_when_null_value_added_using_key_value([Values(1, 2)] int setMethod)
        {
            var h = new HtmlAttributes(name => "Old");

            switch (setMethod)
            {
            case 1:
                h.Attr(name => null);
                break;

            case 2:
                h.Attr("name", null);
                break;
            }

            Assert.That(h.ToHtmlString(), Is.EqualTo(" name=\"\""));
        }
Example #22
0
        public static string Input(this BootstrapRenderer renderer, string name, object value, string type, object htmlAttributes = null)
        {
            var attributes = new HtmlAttributes(htmlAttributes);

            attributes.Merge(new HtmlAttributes(new
            {
                @class = "form-control"
            }));

            return(renderer.Templates.Input.FormatFromDictionary(new Dictionary <string, string>
            {
                { "name", name },
                { "attributes", attributes.ToString() },
                { "type", type },
                { "value", value == null ? String.Empty : value.ToString() }
            }));
        }
Example #23
0
 public static HtmlBuilder Table(
     this HtmlBuilder hb,
     string id  = null,
     string css = null,
     HtmlAttributes attributes = null,
     bool _using   = true,
     Action action = null)
 {
     return(_using
         ? hb.Append(
                tag: "table",
                id: id,
                css: css,
                attributes: attributes,
                action: action)
         : hb);
 }
Example #24
0
        /// <summary>
        /// Creates the HTML for a label.
        /// </summary>
        /// <param name="for">The name/id for the checkbox</param>
        /// <param name="labelText">The text inside the label</param>
        /// <param name="htmlAttributes">Any HTML attributes that should be applied to the checkbox</param>
        /// <returns>The HTML for the checkbox</returns>
        public static IHtmlString BuildLabel(string @for, IHtmlString labelText, HtmlAttributes htmlAttributes)
        {
            var t = new TagBuilder("label");

            if (@for != null)
            {
                t.Attributes.Add("for", TagBuilder.CreateSanitizedId(@for));
            }
            t.InnerHtml = labelText.ToHtmlString();

            if (htmlAttributes != null)
            {
                t.MergeAttributes(htmlAttributes.Attributes, false);
            }

            return(new HtmlString(t.ToString(TagRenderMode.Normal)));
        }
Example #25
0
        private static TagBuilder createInput(string id, object inputAttributes, bool initialValue)
        {
            var input = new TagBuilder("input");

            input.Attributes["id"]    = id;
            input.Attributes["type"]  = "hidden";
            input.Attributes["value"] = initialValue.ToString();

            var attributes = new HtmlAttributes(inputAttributes);

            foreach (var pair in attributes)
            {
                input.Attributes[pair.Key] = pair.Value;
            }

            return(input);
        }
Example #26
0
        private static TagBuilder createPaddle(string id, string enabledText, string disabledText, bool initialValue, object paddleAttributes)
        {
            var paddle = new TagBuilder("div");

            paddle.Attributes["data-paddle"]              = "";
            paddle.Attributes["data-paddle-linkedid"]     = id;
            paddle.Attributes["data-paddle-disable-auto"] = "true";
            paddle.AddCssClass("paddle");
            paddle.AddCssClass(initialValue ? "activated" : "disabled");

            var attributes = new HtmlAttributes(paddleAttributes);

            foreach (var pair in attributes)
            {
                paddle.Attributes[pair.Key] = pair.Value;
            }



            var active = new TagBuilder("div");

            active.AddCssClass("paddle-active");
            active.AddCssClass("paddle-state");
            active.SetInnerText(enabledText);


            var disabled = new TagBuilder("div");

            disabled.AddCssClass("paddle-inactive");
            disabled.AddCssClass("paddle-state");
            disabled.SetInnerText(disabledText);

            var block = new TagBuilder("div");

            block.AddCssClass("paddle-block");

            var builder = new StringBuilder();

            builder.Append(active.ToString(TagRenderMode.Normal));
            builder.Append(disabled.ToString(TagRenderMode.Normal));
            builder.Append(block.ToString(TagRenderMode.Normal));

            paddle.InnerHtml = builder.ToString();
            return(paddle);
        }
        public static string RadioButton(this BootstrapRenderer renderer, string name, object value, string label, bool selected = false, object htmlAttributes = null)
        {
            var defaultAttributes = new HtmlAttributes(new
            {
                @class = "radio"
            });

            var ctx = new Dictionary <string, string>
            {
                { "attributes", new HtmlAttributes(htmlAttributes).Merge(defaultAttributes).ToString() },
                { "name", name },
                { "value", value == null ? string.Empty : value.ToString() },
                { "selected", selected ? " checked" : "" },
                { "label", label }
            };

            return(renderer.Templates.RadioButton.FormatFromDictionary(ctx));
        }
Example #28
0
 public Button(string text, ButtonSettings settings, object htmlAttributes)
 {
     _text          = text;
     _settings      = settings ?? new ButtonSettings();
     HtmlAttributes = new HtmlAttributes(htmlAttributes);
     _settings.UpdateAttributes(HtmlAttributes);
     HtmlAttributes["class"] = "btn";
     if (_settings.Tag == Tag.Input)
     {
         HtmlTag = "input";
         HtmlAttributes["value"] = text;
     }
     else
     {
         HtmlTag   = _settings.Tag.ToString().ToLower();
         InnerHtml = text;
     }
 }
Example #29
0
        override protected XmlElement CreateElement(string ns, string name, HtmlAttributes attributes)
        {
            XmlElement rv = document.CreateElement(name, ns);

            for (int i = 0; i < attributes.Length; i++)
            {
                if (attributes.GetLocalName(i) == "xmlns")
                {
                    continue;
                }
                rv.SetAttribute(attributes.GetLocalName(i), attributes.GetURI(i), attributes.GetValue(i));
                if (attributes.GetType(i) == "ID")
                {
                    //rv.setIdAttributeNS(null, attributes.GetLocalName(i), true); // FIXME
                }
            }
            return(rv);
        }
Example #30
0
        /// <summary>
        /// Creates the HTML for an input.
        /// </summary>
        /// <param name="name">The name/id of the input</param>
        /// <param name="value">The value of the input</param>
        /// <param name="type">The type of the input</param>
        /// <param name="htmlAttributes">Any HTML attributes that should be applied to the button</param>
        /// <returns>The HTML for the input</returns>
        public static IHtmlString BuildInput(string name, string value, string type, HtmlAttributes htmlAttributes)
        {
            var t = new TagBuilder("input");

            if (name != null)
            {
                t.Attributes.Add("name", name);
                t.GenerateId(name);
            }
            t.Attributes.Add("value", value);
            t.Attributes.Add("type", type);
            if (htmlAttributes != null)
            {
                t.MergeAttributes(htmlAttributes.Attributes, true);
            }

            return(new HtmlString(t.ToString(TagRenderMode.SelfClosing)));
        }
Example #31
0
 public static HtmlBuilder Caption(
     this HtmlBuilder hb,
     string caption,
     string id  = null,
     string css = null,
     HtmlAttributes attributes = null,
     bool _using = true)
 {
     return(_using
         ? hb.Append(
                tag: "caption",
                id: id,
                css: css,
                attributes: attributes,
                action: () => hb
                .Text(text: caption))
         : hb);
 }
        /// <summary>
        /// Creates the root HTML element.
        /// </summary>
        ///
        /// <param name="attributes">
        /// The attributes.
        /// </param>
        ///
        /// <returns>
        /// The new HTML element.
        /// </returns>

        override protected DomObject CreateHtmlElementSetAsRoot(HtmlAttributes attributes)
        {
            if (!isFragment)
            {
                DomElement rv = DomElement.Create("html");
                for (int i = 0; i < attributes.Length; i++)
                {
                    string attributeName = AttributeName(attributes.GetLocalName(i), attributes.GetURI(i));
                    rv.SetAttribute(attributeName, attributes.GetValue(i));
                }
                Document.AppendChildUnsafe(rv);
                return(rv);
            }
            else
            {
                return(Document);
            }
        }
Example #33
0
 public static HtmlBuilder Select(
     this HtmlBuilder hb,
     string id   = null,
     string name = null,
     string css  = null,
     HtmlAttributes attributes = null,
     bool _using   = true,
     Action action = null)
 {
     return(_using
         ? hb.Append(
                tag: "select",
                attributes: (attributes ?? new HtmlAttributes())
                .Id(id)
                .Name(name)
                .Class(css),
                action: action)
         : hb);
 }
Example #34
0
        /// <summary>
        /// Writes the specified <see cref="HtmlAttributes"/>.
        /// </summary>
        /// <param name="attributes">The attributes to render.</param>
        /// <returns>This instance</returns>
        public HtmlRenderer WriteAttributes(HtmlAttributes attributes)
        {
            if (attributes == null)
            {
                return(this);
            }

            if (attributes.Id != null)
            {
                Write(" id=\"").WriteEscape(attributes.Id).Write("\"");
            }

            if (attributes.Classes != null && attributes.Classes.Count > 0)
            {
                Write(" class=\"");
                for (int i = 0; i < attributes.Classes.Count; i++)
                {
                    var cssClass = attributes.Classes[i];
                    if (i > 0)
                    {
                        Write(" ");
                    }
                    WriteEscape(cssClass);
                }
                Write("\"");
            }

            if (attributes.Properties != null && attributes.Properties.Count > 0)
            {
                foreach (var property in attributes.Properties)
                {
                    Write(" ").Write(property.Key);
                    if (property.Value != null)
                    {
                        Write("=").Write("\"");
                        WriteEscape(property.Value);
                        Write("\"");
                    }
                }
            }

            return(this);
        }
Example #35
0
 private static HtmlBuilder LabelValue(
     this HtmlBuilder hb,
     string label,
     string value,
     bool bold,
     HtmlAttributes attributes)
 {
     return(hb.Span(attributes: attributes, action: () =>
     {
         if (label != string.Empty)
         {
             hb.Span(
                 css: bold ? "bold" : null,
                 action: () => hb
                 .Text(label));
         }
         hb.Text(value);
     }));
 }
Example #36
0
		// ]NOCPP]

		/**
		 * The constructor.
		 * 
		 * @param tokenHandler
		 *            the handler for receiving tokens
		 */
		public Tokenizer(ITokenHandler tokenHandler)
		{
			this.TokenHandler = tokenHandler;
			// [NOCPP[
			this.newAttributesEachTime = false;
			// ]NOCPP]
			this.bmpChar = new char[1];
			this.astralChar = new char[2];
			this.tagName = null;
			this.attributeName = null;
			this.doctypeName = null;
			this.publicIdentifier = null;
			this.systemIdentifier = null;
			this.attributes = null;
		}
Example #37
0
 protected void MaybeErrAttributesOnEndTag(HtmlAttributes attrs)
 {
 }
Example #38
0
 public void End()
 {
     this.strBuffer = null;
     this.longStrBuffer.Length = 0;
     this.longStrBuffer = null;
     doctypeName = null;
     systemIdentifier = null;
     publicIdentifier = null;
     tagName = null;
     attributeName = null;
     TokenListener.EndTokenization();
     if (attributes != null)
     {
         attributes.Clear(mappingLangToXmlLang);
         attributes = null;
     }
 }
Example #39
0
 public void AddHtmlAttribute(HtmlAttributes attribute, String attributeValue)
 {
     String attributeId = Resolvers.HtmlResolver.GenerateHtmlAttributeString(attribute);
     if (this.HtmlAttributes.ContainsKey(attributeId))
     {
         this.HtmlAttributes[attributeId] = attributeValue;
     }
     else
     {
         this.HtmlAttributes.Add(attributeId, attributeValue);
     }
 }
Example #40
0
        public void InitializeWithoutStarting()
        {

            this.strBuffer = new StringBuilder();
            line = 1;
            this.longStrBuffer = new StringBuilder();
            // [NOCPP[
            html4 = false;
            metaBoundaryPassed = false;
            wantsComments = TokenListener.WantsComments;

            if (!newAttributesEachTime)
            {
                attributes = new HtmlAttributes(mappingLangToXmlLang);
            }
            // ]NOCPP]
            ResetToDataState();
        }
public static System.Web.WebPages.HelperResult BeginSection(IHtmlString heading, IHtmlString leadingHtml, HtmlAttributes htmlAttributes) {
#line default
#line hidden
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {

#line 13 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
                                                                                                   


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "    <fieldset");


#line 14 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, htmlAttributes);


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, ">\r\n");


#line 15 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    if (heading != null && !string.IsNullOrWhiteSpace(heading.ToString()))
    {


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "        <legend>");


#line 17 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, heading);


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "</legend>\r\n");


#line 18 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    }
    if (leadingHtml != null && !string.IsNullOrWhiteSpace(leadingHtml.ToString()))
    {


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "        ");


#line 21 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, leadingHtml);


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "\r\n");


#line 22 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    }


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "        <dl>\r\n");


#line 24 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"


#line default
#line hidden
});

#line 24 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
}
        public void ResetToDataState()
        {
            strBufLen = 0;
            longStrBufLen = 0;
            stateSave = Tokenizer.DATA;
            // line = 1; XXX line numbers
            lastCR = false;
            index = 0;
            forceQuirks = false;
            additional = '\u0000';
            entCol = -1;
            firstCharKey = -1;
            lo = 0;
            hi = 0; // will always be overwritten before use anyway
            candidate = -1;
            strBufMark = 0;
            prevValue = -1;
            value = 0;
            seenDigits = false;
            endTag = false;
            shouldSuspend = false;
            InitDoctypeFields();
            if (tagName != null)
            {
                tagName = null;
            }
            if (attributeName != null)
            {
                attributeName = null;
            }

            if (attributes != null)
            {
                attributes = null;
            }
        }
Example #43
0
		public Tokenizer(ITokenHandler tokenHandler, bool newAttributesEachTime)
		{
			this.TokenHandler = tokenHandler;
			this.newAttributesEachTime = newAttributesEachTime;
			this.bmpChar = new char[1];
			this.astralChar = new char[2];
			this.tagName = null;
			this.attributeName = null;
			this.doctypeName = null;
			this.publicIdentifier = null;
			this.systemIdentifier = null;
			this.attributes = null;
		}
Example #44
0
 void TreeBuilder_OnStartTag(ElementName eltName, HtmlAttributes attributes, bool selfClosing)
 {
     GlobalLog.Write(string.Format("Start tag {0} with {1} attributes, selfClosing <{2}>", eltName.name, attributes.Length, selfClosing), "TreeBulder");
 }
Example #45
0
		private void AttributeNameComplete()
		{
			// if (strBufOffset != -1) {
			// attributeName = AttributeName.nameByBuffer(buf, strBufOffset,
			// strBufLen, namePolicy != XmlViolationPolicy.ALLOW);
			// } else {
			attributeName = AttributeName.NameByBuffer(strBuf, 0, strBufLen
				// [NOCPP[
					, namePolicy != XmlViolationPolicy.Allow
				// ]NOCPP]
					);
			// }

			if (attributes == null)
			{
				attributes = new HtmlAttributes(mappingLangToXmlLang);
			}

			/*
			 * When the user agent leaves the attribute name state (and before
			 * emitting the tag token, if appropriate), the complete attribute's
			 * name must be compared to the other attributes on the same token; if
			 * there is already an attribute on the token with the exact same name,
			 * then this is a parse error and the new attribute must be dropped,
			 * along with the value that gets associated with it (if any).
			 */
			if (attributes.Contains(attributeName))
			{
				ErrDuplicateAttribute();
				attributeName = null;
			}
		}
Example #46
0
		/**
		 * 
		 */
		private void ResetAttributes()
		{
			// [NOCPP[
			if (newAttributesEachTime)
			{
				// ]NOCPP]
				attributes = null;
				// [NOCPP[
			}
			else
			{
				attributes.Clear(mappingLangToXmlLang);
			}
			// ]NOCPP]
		}
        /**
         * The constructor.
         *
         * @param tokenHandler
         *            the handler for receiving tokens
         */
        public Tokenizer(ITreeBuilder tokenHandler)
        {
            this.TokenHandler = tokenHandler;

            this.bmpChar = new char[1];
            this.astralChar = new char[2];
            this.tagName = null;
            this.attributeName = null;
            this.doctypeName = null;
            this.publicIdentifier = null;
            this.systemIdentifier = null;
            this.attributes = null;
        }
 private void ResetAttributes()
 {
     attributes = null;
 }
        private void AttributeNameComplete()
        {
            attributeName = AttributeName.NameByBuffer(strBuf, 0, strBufLen);

            if (attributes == null)
            {
                attributes = new HtmlAttributes(mappingLangToXmlLang);
            }

            /*
             * When the user agent leaves the attribute name state (and before
             * emitting the tag token, if appropriate), the complete attribute's
             * name must be compared to the other attributes on the same token; if
             * there is already an attribute on the token with the exact same name,
             * then this is a parse error and the new attribute must be dropped,
             * along with the value that gets associated with it (if any).
             */
            if (attributes.Contains(attributeName))
            {
                ErrDuplicateAttribute();
                attributeName = null;
            }
        }
public static System.Web.WebPages.HelperResult BeginNestedSection(IHtmlString heading, IHtmlString leadingHtml, HtmlAttributes htmlAttributes)
{
#line default
#line hidden
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {

#line 27 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
 
    if (heading != null && !string.IsNullOrWhiteSpace(heading.ToString()))
    {


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "            <dt>");


#line 30 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, heading);


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "</dt>\r\n");


#line 31 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    }


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "            <dd>\r\n");


#line 33 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    if (leadingHtml != null && !string.IsNullOrWhiteSpace(leadingHtml.ToString()))
    {


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "                ");


#line 35 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, leadingHtml);


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "\r\n");


#line 36 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    }


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "                <dl");


#line 37 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, htmlAttributes);


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, ">\r\n");


#line 38 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"


#line default
#line hidden
});

#line 38 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
}
Example #51
0
		public void End()
		{
			strBuf = null;
			longStrBuf = null;
			doctypeName = null;
			systemIdentifier = null;
			publicIdentifier = null;
			tagName = null;
			attributeName = null;
			TokenHandler.EndTokenization();
			if (attributes != null)
			{
				attributes.Clear(mappingLangToXmlLang);
				attributes = null;
			}
		}
Example #52
0
 void TreeBuilder_OnCreateElement(string ns, string name, HtmlAttributes attributes)
 {
     GlobalLog.Write(string.Format("CreateElement {0} with {1} attributes", name, attributes.Length), "TreeBulder");
 }
Example #53
0
		public void ResetToDataState()
		{
			strBufLen = 0;
			longStrBufLen = 0;
            stateSave = TokenizerState.DATA;
			// line = 1; XXX line numbers
			lastCR = false;
			index = 0;
			forceQuirks = false;
			additional = '\u0000';
			entCol = -1;
			firstCharKey = -1;
			lo = 0;
			hi = 0; // will always be overwritten before use anyway
			candidate = -1;
			strBufMark = 0;
			prevValue = -1;
			value = 0;
			seenDigits = false;
			endTag = false;
            // Removed J. Treworgy 12/7/2012 - this should remain true so the parser can choose to abort 
			//shouldSuspend = false;
			InitDoctypeFields();
			if (tagName != null)
			{
				tagName = null;
			}
			if (attributeName != null)
			{
				attributeName = null;
			}
			// [NOCPP[
			if (newAttributesEachTime)
			{
				// ]NOCPP]
				if (attributes != null)
				{
					attributes = null;
				}
				// [NOCPP[
			}
			// ]NOCPP]
		}
 protected override void maybeErrAttributesOnEndTag(HtmlAttributes attrs)
 {
     if (attrs.getLength() != 0) {
         /*
          * When an end tag token is emitted with attributes, that is a parse
          * error.
          */
         err("End tag had attributes.");
     }
 }
Example #55
0
		public void LoadState(Tokenizer other)
		{
			strBufLen = other.strBufLen;
			if (strBufLen > strBuf.Length)
			{
				strBuf = new char[strBufLen];
			}
			//Array.Copy(other.strBuf, strBuf, strBufLen);
		    Buffer.BlockCopy(other.strBuf, 0, strBuf, 0, strBufLen << 1);
            
			longStrBufLen = other.longStrBufLen;
			if (longStrBufLen > longStrBuf.Length)
			{
				longStrBuf = new char[longStrBufLen];
			}
			//Array.Copy(other.longStrBuf, longStrBuf, longStrBufLen);
            Buffer.BlockCopy(other.longStrBuf, 0, longStrBuf, 0,longStrBufLen<< 1);

			stateSave = other.stateSave;
			returnStateSave = other.returnStateSave;
			endTagExpectation = other.endTagExpectation;
			endTagExpectationAsArray = other.endTagExpectationAsArray;
			// line = 1; XXX line numbers
			lastCR = other.lastCR;
			index = other.index;
			forceQuirks = other.forceQuirks;
			additional = other.additional;
			entCol = other.entCol;
			firstCharKey = other.firstCharKey;
			lo = other.lo;
			hi = other.hi;
			candidate = other.candidate;
			strBufMark = other.strBufMark;
			prevValue = other.prevValue;
			value = other.value;
			seenDigits = other.seenDigits;
			endTag = other.endTag;
			shouldSuspend = false;

			if (other.doctypeName == null)
			{
				doctypeName = null;
			}
			else
			{
				doctypeName = other.doctypeName;
			}

			if (other.systemIdentifier == null)
			{
				systemIdentifier = null;
			}
			else
			{
				systemIdentifier = other.systemIdentifier;
			}

			if (other.publicIdentifier == null)
			{
				publicIdentifier = null;
			}
			else
			{
				publicIdentifier = other.publicIdentifier;
			}

			if (other.tagName == null)
			{
				tagName = null;
			}
			else
			{
				tagName = other.tagName.CloneElementName();
			}

			if (other.attributeName == null)
			{
				attributeName = null;
			}
			else
			{
				attributeName = other.attributeName.CloneAttributeName();
			}
            
			if (other.attributes == null)
			{
				attributes = null;
			}
			else
			{
				attributes = other.attributes.CloneAttributes();
			}
		}
Example #56
0
		public void InitializeWithoutStarting()
		{
			confident = false;
			strBuf = new char[64];
			longStrBuf = new char[1024];
			line = 1;
			// [NOCPP[
			html4 = false;
			metaBoundaryPassed = false;
			wantsComments = TokenHandler.WantsComments;

			if (!newAttributesEachTime)
			{
				attributes = new HtmlAttributes(mappingLangToXmlLang);
			}
			// ]NOCPP]
			ResetToDataState();
		}
public static System.Web.WebPages.HelperResult BeginNestedSection(IHtmlString heading, IHtmlString leadingHtml, HtmlAttributes htmlAttributes)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {



#line 29 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
 
    htmlAttributes.AddClass("panel panel-default");

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "    <div");



#line 31 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
WebViewPage.WriteTo(@__razor_helper_writer, htmlAttributes);

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_helper_writer, ">\r\n");



#line 32 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
    if (heading != null && !string.IsNullOrWhiteSpace(heading.ToString()))
    {

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "        <div class=\"panel-heading\">");



#line 34 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
WebViewPage.WriteTo(@__razor_helper_writer, heading);

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</div>\r\n");



#line 35 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
    }


#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "        <div class=\"panel-body\">\r\n");



#line 38 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
    if (leadingHtml != null && !string.IsNullOrWhiteSpace(leadingHtml.ToString()))
    {
        
#line default
#line hidden


#line 40 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
WebViewPage.WriteTo(@__razor_helper_writer, leadingHtml);

#line default
#line hidden


#line 40 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
                    
    }

#line default
#line hidden

});

}