/// <summary> /// The <c><blockquote></c> tag specifies a section that is quoted from another source. <remarks></remarks> /// Browsers usually indent <c><blockquote></c> elements.<remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_blockquote.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="definitionSource">Specifies the source of the quotation<c> [cite]</c> (Optional)</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement BlockQuote(this IBuilder builder, Uri definitionSource = null, IHtmlAttributes attributes = null) { var newAttributes = attributes ?? new HtmlAttributes(); if(definitionSource != null) newAttributes.Add("cite", definitionSource.ToString()); return BlockQuoteElement(builder, newAttributes); }
/// <summary> /// The <c><abbr></c> tag defines an abbreviation or an acronym, like "Mr.", "Dec.", "ASAP", "ATM".<remarks></remarks> /// Tip: An abbreviation and an acronym are both shortened versions of something else. Both is often represented as a series of letters.<remarks></remarks> /// Marking up abbreviations can give useful information to browsers, translation systems and search-engines.<remarks> </remarks> /// For more information see: <see cref="http://www.w3schools.com/tags/tag_abbr.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="definition">The definition to what the Abbreviation stands for</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement Abbreviation(this IBuilder builder, string definition, IHtmlAttributes attributes = null) { var newAttributes = attributes ?? new HtmlAttributes(); newAttributes.Add("title", definition); return AbbreviationElement(builder, newAttributes); }
/// <summary> /// The <c><h1></c> to <c><h6></c> tags are used to define HTML headings. <remarks></remarks> /// <c><h1></c> defines the most important heading. <c><h6></c> defines the least important heading. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_hn.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="tier">The tier of the Heading element</param> /// <param name="text">The text value of the Heading element</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement Heading( this IBuilder builder, string text, HeadingTier tier, IHtmlAttributes attributes = null) { return builder.CreateElement(tier.ToString(), false, attributes).SetText(text); }
/// <summary> /// The <c><col></c> tag defines a table caption. <remarks></remarks> /// The <c><col></c> tag must be inserted immediately after the <c><table></c> tag. <remarks></remarks> /// Note: You can specify only one caption per table. <remarks></remarks> /// Tip: By default, a table caption will be center-aligned above a table. However, the CSS properties text-align and caption-side can be used to align and place the caption. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_col.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="span">Specifies the number of columns a <c><col></c> element should span (optional)</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement Column( this IBuilder builder, int span = 0, IHtmlAttributes attributes = null) { var newAttributes = attributes ?? new HtmlAttributes(); if (span != 0) newAttributes.Add("span", span.ToString()); return ColumnElement(builder, attributes); }
public static IHtmlElement Link(this IBuilder builder, Uri sourceReference, IHtmlAttributes attributes = null) { var newAttributes = attributes ?? new HtmlAttributes(); newAttributes.Add("src", sourceReference.ToString()); newAttributes.Add("rel", LinkRelationType.StyleSheet.ToString()); return LinkElement(builder, newAttributes); }
public static IHtmlElement Script(this IBuilder builder, Uri sourceReference, ScriptSourceType sourceType, IHtmlAttributes attributes = null) { var newAttributes = attributes ?? new HtmlAttributes(); newAttributes.Add("src", sourceReference.ToString()); newAttributes.Add("type", sourceType.ToString()); return ScriptElement(builder, newAttributes); }
/// <summary> /// The <c><base></c> tag specifies the base URL/target for all relative URLs in a document. /// There can be at maximum one <c><base></c> element in a document, and it must be inside the <c><head></c> element. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_base.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="address">Specifies the base URL for all relative URLs in the page<c> [href]</c></param> /// <param name="target">Specifies the default target for all hyperlinks and forms in the page<c> [target="_blank | _parent | _self | _top | <frameName>"]</c> (optional)</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement Base( this IBuilder builder, Uri address, HyperLinkTarget target = null, IHtmlAttributes attributes = null) { var newAttributes = attributes ?? new HtmlAttributes(); newAttributes.Add("href", address.ToString()); if (target != null) newAttributes.Add("target", target.ToString()); return BaseElement(builder, newAttributes); }
// ReSharper restore InconsistentNaming public HtmlElement(IBuilder builder, string tagName, bool selfClosing = false, IHtmlAttributes attributes = null) { _tagName = tagName; _tagBuilder = new TagBuilder(String.IsNullOrWhiteSpace(_tagName) ? "____EMPTY_TAG____" : _tagName); _viewBuilder = builder; _selfClosing = selfClosing; _attributes = attributes ?? new HtmlAttributes(); if (String.IsNullOrWhiteSpace(_tagName)) return; foreach (var attribute in _attributes) _tagBuilder.Attributes.Add((KeyValuePair<string, string>)attribute); _viewBuilder.Append(_tagBuilder.ToString(_selfClosing ? TagRenderMode.SelfClosing : TagRenderMode.StartTag)); }
/// <summary> /// The <c><audio></c> tag defines sound, such as music or other audio streams. /// Currently, there are 3 supported file formats for the <c><audio></c> element: MP3, Wav, and Ogg:<remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_audio.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="source">The URI pointing to the audio source<c> [src]</c></param> /// <param name="mimeType"> /// The MimeType of the audioFile<c> [type]</c> (Optional) <remarks></remarks> /// If left blank the mimetype will be resolved by the file extension /// </param> /// <param name="autoplay">Specifies that the audio will start playing as soon as it is ready (optional)</param> /// <param name="controls">Specifies that audio controls should be displayed (such as a play/pause button etc) (optional)</param> /// <param name="loop">Specifies that the audio will start over again, every time it is finished (optional)</param> /// <param name="muted">Specifies that the audio output should be muted (optional)</param> /// <param name="preload">Specifies if and how the author thinks the audio should be loaded when the page loads<c> [auto|metadata|none]</c> (optional)</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement Audio(this IBuilder builder, Uri source, string mimeType = null, bool? autoplay = null, bool? controls = null, bool? loop = null, bool? muted = null, MediaPreloadType preload = null, IHtmlAttributes attributes = null) { mimeType = CheckFileExtension(source, mimeType); var newAttributes = attributes ?? new HtmlAttributes(); newAttributes.Add("href", source.ToString()); newAttributes.Add("type", mimeType); if(autoplay.HasValue) newAttributes.Add("autoplay", nameof(autoplay)); if(controls.HasValue) newAttributes.Add("controls", nameof(autoplay)); if(loop.HasValue) newAttributes.Add("loop", nameof(loop)); if(muted.HasValue) newAttributes.Add("muted", nameof(muted)); if(preload != null) newAttributes.Add("preload", preload.ToString()); return AudioElement(builder, newAttributes); }
/// <summary> /// The <c><col></c> tag defines a table caption. <remarks></remarks> /// The <c><col></c> tag must be inserted immediately after the <c><table></c> tag. <remarks></remarks> /// Note: You can specify only one caption per table. <remarks></remarks> /// Tip: By default, a table caption will be center-aligned above a table. However, the CSS properties text-align and caption-side can be used to align and place the caption. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_col.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement ColumnElement(IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("col", false, attributes); }
/// <summary> /// The <c><canvas></c> tag is used to draw graphics, on the fly, via scripting (usually JavaScript). <remarks></remarks> /// The <c><canvas></c> tag is only a container for graphics, you must use a script to actually draw the graphics. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_canvas.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement Canvas(this IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("canvas", false, attributes); }
protected string RenderAttributes(IHtmlAttributes attribs) { if (attribs.Count > 4) { int totalLength = attribs.GetEstLength(); var sb = new StringBuilder(totalLength + 10); foreach (var attrib in attribs) { //format " [attribute]="[value encoded]"" sb.Append(" ").Append(attrib.Key).Append("=\""); if (attrib.Key == "id" || ( _element.Tag == "label" && attrib.Key == "for")) sb.Append(EncodeAttribute(attrib.Value.Replace('.', '-'))).Append("\""); else sb.Append(EncodeAttribute(attrib.Value)).Append("\""); } return sb.ToString().Trim(); } else { string val = string.Empty; foreach (var attrib in attribs) { if (attrib.Key == "id" || (_element.Tag == "label" && attrib.Key == "for")) val += string.Format(" {0}=\"{1}\"", attrib.Key, EncodeAttribute(attrib.Value.Replace('.', '-'))); else val += string.Format(" {0}=\"{1}\"", attrib.Key, EncodeAttribute(attrib.Value)); } return val.Trim(); } }
/// <summary> /// The <c><audio></c> tag defines sound, such as music or other audio streams. /// Currently, there are 3 supported file formats for the <c><audio></c> element: MP3, Wav, and Ogg:<remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_audio.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement AudioElement(IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("a", false, attributes); }
/// <summary> /// The <c><datalist></c> tag specifies a list of pre-defined options for an <c><input></c> element. <remarks></remarks> /// The <c><datalist></c> tag is used to provide an "autocomplete" feature on <c><input></c> elements.Users will see a drop-down list of pre-defined options as they input data. <remarks></remarks> /// Use the <c><input></c> element's list attribute to bind it together with a <c><datalist></c> element. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_datalist.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement DataList(this IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("datalist", false, attributes); }
public IHtmlElement CreateElement(string tagName, bool selfClosing = false, IHtmlAttributes attributes = default(HtmlAttributes)) { return new HtmlElement(this, tagName, selfClosing, attributes); }
/// <summary> /// The <c><aside></c> defines some content aside from the content it is placed in. <remarks></remarks> /// The aside content should be related to the surrounding content. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_aside.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement Aside(this IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("aside", false, attributes); }
public static IHtmlElement ScriptElement(IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("script", false, attributes); }
/// <summary> /// Gets the specified attribute value. /// </summary> public static TValue Attr <TValue>(this IHtmlAttributes instance, string attributeName) { return(instance.HtmlAttributes.Get <TValue>(attributeName)); }
public static IHtmlElement Html(this IBuilder builder, IHtmlAttributes attributes = null) { builder.Prepend("<!doctype html>"); return builder.CreateElement("html", false, attributes); }
/// <summary> /// The <c><abbr></c> tag defines an abbreviation or an acronym, like "Mr.", "Dec.", "ASAP", "ATM". <remarks></remarks> /// Tip: An abbreviation and an acronym are both shortened versions of something else. Both is often represented as a series of letters. <remarks></remarks> /// Marking up abbreviations can give useful information to browsers, translation systems and search-engines. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_abbr.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> public static IHtmlElement AbbreviationElement(IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("abbr", false, attributes); }
/// <summary> /// The <c><li></c> tag defines a list item. /// The <c><li></c> tag is used in ordered lists(<c><ol></c>), unordered lists(<c><ul></c>), and in menu lists(<c><menu></c>). <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_li.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement ListItem(this IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("li", false, attributes); }
/// <summary> /// The <c><ol></c> tag defines an ordered list. An ordered list can be numerical or alphabetical. <remarks></remarks> /// Use the <c><li></c> tag to define list items. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_ol.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement OrderedList(this IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("ol", false, attributes); }
/// <summary> /// The <c><body></c> tag defines the document's body. <remarks></remarks> /// The <c><body></c> element contains all the contents of an HTML document, such as text, /// hyperlinks, images, tables, lists, etc. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_body.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement Body(this IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("body", false, attributes); }
/// <summary> /// The <c><dt></c> tag defines a term/name in a description list. <remarks></remarks> /// The <c><dt></c> tag is used in conjunction with <c><dl></c> (defines a description list) and <c><dd></c> (describes each term/name). <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_dt.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement DescriptionTerm(this IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("dt", false, attributes); }
/// <summary> /// The <c><base></c> tag specifies the base URL/target for all relative URLs in a document. /// There can be at maximum one <c><base></c> element in a document, and it must be inside the <c><head></c> element. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_base.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement BaseElement(IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("base", true, attributes); }
/// <summary> /// The <c><br></c> tag inserts a single line break. <remarks></remarks> /// The <c><br></c> tag is an empty tag which means that it has no end tag. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_body.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement LineBreak(this IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("br", true, attributes); }
public static IHtmlElement Paragraph(this IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("p", false, attributes); }
/// <summary> /// The <c><button></c> tag defines a clickable button.<remarks></remarks> /// Inside a <c><button></c> element you can put content, like text or images. <remarks></remarks> /// This is the difference between this element and buttons created with the <c><input></c> element. <remarks></remarks> /// Tip: Always specify the type attribute for a <c><button></c> element. Different browsers use different default types for the <c><button></c> element. <remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_button.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes</param> /// <returns></returns> public static IHtmlElement ButtonElement(IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("button", false, attributes); }
/// <summary> /// The <c><blockquote></c> tag specifies a section that is quoted from another source. <remarks></remarks> /// Browsers usually indent <c><blockquote></c> elements.<remarks> </remarks> /// /// For more information see: <see cref="http://www.w3schools.com/tags/tag_blockquote.asp"/> /// </summary> /// <param name="builder">Builder for the Html Component</param> /// <param name="attributes">Standard HTML Attributes (optional)</param> /// <returns></returns> public static IHtmlElement BlockQuoteElement(IBuilder builder, IHtmlAttributes attributes = null) { return builder.CreateElement("blockquote", false, attributes); }
public Element(string tag, IDictionary attributes) { _escapeInnerText = false; _tag = tag.ToLower(); _attributes = new HtmlAttributes(attributes); }