Пример #1
0
 /// <summary>
 /// The <c>&lt;blockquote></c> tag specifies a section that is quoted from another source. <remarks></remarks>
 /// Browsers usually indent <c>&lt;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);
 }
Пример #2
0
 /// <summary>
 /// The <c>&lt;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);
 }
Пример #3
0
 /// <summary>
 /// The <c>&lt;h1></c> to <c>&lt;h6></c> tags are used to define HTML headings. <remarks></remarks>
 /// <c>&lt;h1></c> defines the most important heading. <c>&lt;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);
 }
Пример #4
0
 /// <summary>
 /// The <c>&lt;col></c> tag defines a table caption. <remarks></remarks>
 /// The <c>&lt;col></c> tag must be inserted immediately after the <c>&lt;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>&lt;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);
 }
Пример #5
0
 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);
 }
Пример #6
0
 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);
 }
Пример #7
0
 /// <summary>
 /// The <c>&lt;base></c> tag specifies the base URL/target for all relative URLs in a document.
 /// There can be at maximum one <c>&lt;base></c> element in a document, and it must be inside the <c>&lt;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 | &lt;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);
 }
Пример #8
0
        // 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));
        }
Пример #9
0
 /// <summary>
 /// The <c>&lt;audio></c> tag defines sound, such as music or other audio streams.
 /// Currently, there are 3 supported file formats for the <c>&lt;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);
 }
Пример #10
0
 /// <summary>
 /// The <c>&lt;col></c> tag defines a table caption. <remarks></remarks>
 /// The <c>&lt;col></c> tag must be inserted immediately after the <c>&lt;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);
 }
Пример #11
0
 /// <summary>
 /// The <c>&lt;canvas></c> tag is used to draw graphics, on the fly, via scripting (usually JavaScript). <remarks></remarks>
 /// The <c>&lt;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);
 }
Пример #12
0
 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();
     }
 }
Пример #13
0
 /// <summary>
 /// The <c>&lt;audio></c> tag defines sound, such as music or other audio streams.
 /// Currently, there are 3 supported file formats for the <c>&lt;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);
 }
Пример #14
0
 /// <summary>
 /// The <c>&lt;datalist></c> tag specifies a list of pre-defined options for an <c>&lt;input></c> element. <remarks></remarks>
 /// The <c>&lt;datalist></c> tag is used to provide an "autocomplete" feature on <c>&lt;input></c> elements.Users will see a drop-down list of pre-defined options as they input data. <remarks></remarks>
 /// Use the <c>&lt;input></c> element's list attribute to bind it together with a <c>&lt;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);
 }
Пример #15
0
 public IHtmlElement CreateElement(string tagName, bool selfClosing = false, IHtmlAttributes attributes = default(HtmlAttributes))
 {
     return new HtmlElement(this, tagName, selfClosing, attributes);
 }
Пример #16
0
 /// <summary>
 /// The <c>&lt;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);
 }
Пример #17
0
 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));
 }
Пример #19
0
 public static IHtmlElement Html(this IBuilder builder, IHtmlAttributes attributes = null)
 {
     builder.Prepend("<!doctype html>");
     return builder.CreateElement("html", false, attributes);
 }
Пример #20
0
 /// <summary>
 /// The <c>&lt;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);
 }
Пример #21
0
 /// <summary>
 /// The <c>&lt;li></c> tag defines a list item.
 /// The <c>&lt;li></c> tag is used in ordered lists(<c>&lt;ol></c>), unordered lists(<c>&lt;ul></c>), and in menu lists(<c>&lt;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);
 }
Пример #22
0
 /// <summary>
 /// The <c>&lt;ol></c> tag defines an ordered list. An ordered list can be numerical or alphabetical. <remarks></remarks>
 /// Use the <c>&lt;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);
 }
Пример #23
0
 /// <summary>
 /// The <c>&lt;body></c> tag defines the document's body. <remarks></remarks>
 /// The <c>&lt;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);
 }
Пример #24
0
 /// <summary>
 /// The <c>&lt;dt></c> tag defines a term/name in a description list. <remarks></remarks>
 /// The <c>&lt;dt></c> tag is used in conjunction with <c>&lt;dl></c> (defines a description list) and <c>&lt;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);
 }
Пример #25
0
 /// <summary>
 /// The <c>&lt;base></c> tag specifies the base URL/target for all relative URLs in a document.
 /// There can be at maximum one <c>&lt;base></c> element in a document, and it must be inside the <c>&lt;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);
 }
Пример #26
0
 /// <summary>
 /// The <c>&lt;br></c> tag inserts a single line break. <remarks></remarks>
 /// The <c>&lt;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);
 }
Пример #27
0
 public static IHtmlElement Paragraph(this IBuilder builder, IHtmlAttributes attributes = null)
 {
     return builder.CreateElement("p", false, attributes);
 }
Пример #28
0
 /// <summary>
 /// The <c>&lt;button></c> tag defines a clickable button.<remarks></remarks>
 /// Inside a <c>&lt;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>&lt;input></c> element. <remarks></remarks>
 /// Tip: Always specify the type attribute for a <c>&lt;button></c> element. Different browsers use different default types for the <c>&lt;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);
 }
Пример #29
0
 /// <summary>
 /// The <c>&lt;blockquote></c> tag specifies a section that is quoted from another source. <remarks></remarks>
 /// Browsers usually indent <c>&lt;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);
 }
Пример #30
0
 public Element(string tag, IDictionary attributes)
 {
     _escapeInnerText = false;
     _tag = tag.ToLower();
     _attributes = new HtmlAttributes(attributes);
 }