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
| Constructor. |
|
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 | |
Sets the contents of the tag. Any objects are allowed. |
void | |
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> | |
Outputs this tag and all its contents. |
string | |
Converts the entire tag tree into a single string. |
string | |
void | |
Creates a new file and outputs this tag and all its contents to it. |
Static methods
Tag | |
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> | |
Converts a tag tree into a string that is generated bit by bit. |
RawTag | | 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 | | Whether the end tag should be printed. |
bool | | Whether the start tag should be printed. If the tag has attributes, it will be printed regardless. |
string | | Name of the tag. |