Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Abstract class: RT.TagSoup.Tag

Summary

Abstract base class for an HTML tag.

Remarks

The following types are supported in tag contents:

  • string
    outputs that string (HTML-escaped, of course)
  • Tag
    outputs that tag and its contents
  • IEnumerable<T>
    enumerates all contained objects and recursively processes them individually
  • Func<T> (or any other delegate with no parameters)
    calls the delegate and recursively processes the return value

Using lazy-evaluated IEnumerable<T>s and/or delegates is a convenient way to defer execution to ensure maximally responsive output.

Constructors

Tag()
Constructor.
Tag(object[] contents)
Tag(IEnumerable contents)

Instance methods

Tag
_(params object[] contents)
Sets the contents of the tag. Any objects are allowed.
Tag
_(params Func<object>[] contents)
Sets the contents of the tag using lazy evaluation.
Tag
_(IEnumerable contents)
Sets the contents of the tag. Any objects are allowed.
void
Add(object content)
Adds stuff at the end of the contents of this tag (a string, a tag, a collection of strings or of tags).
Tag
Data(string key, object value)
Specifies a data attribute for this tag.
IEnumerable<string>
ToEnumerable(bool allTags = false)
  • Virtual
Outputs this tag and all its contents.
string
  • Overrides: object.ToString()
Converts the entire tag tree into a single string.
string
ToString(bool allTags)
void
WriteToFile(string filename, bool allTags = false)
Creates a new file and outputs this tag and all its contents to it.

Static methods

Tag
HtmlDocument(object title, params object[] bodyContent)
Creates a simple HTML document from the specified elements.
Tag
HtmlTable(string classOnAllTags, params object[][] rows)
Special method to help construct an HTML <TABLE> element without needing to manually instantiate all intermediate row and cell tags.
IEnumerable<string>
ToEnumerable(object tagTree, bool allTags = false)
Converts a tag tree into a string that is generated bit by bit.
RawTag
ToRaw(object tagTree)
Converts a tag tree into a raw tag which would render exactly the same as the tag tree.
RawTag
ToRaw(params object[] tagTree)
string
ToString(object tagTree, bool allTags = false)
Converts a tag tree into a single string.

Instance properties

bool
  • Virtual
Whether the end tag should be printed.
bool
  • Virtual
Whether the start tag should be printed. If the tag has attributes, it will be printed regardless.
string
  • Abstract
Name of the tag.