Class Tag<T>
Helper commands to enable fluid coding with Tag Attributes and Common Helpers like Add and Wrap.
This allows you to do things like
Div().Id("myId").Class("row4").Class("xs")
Inheritance
System.Object
ToSic.Razor.Markup.RawHtmlString
Tag<T>
Implements
System.Web.IHtmlString
System.Collections.Generic.IEnumerable<
ITag>
System.Collections.IEnumerable
Assembly: ToSic.Razor.dll
Syntax
public abstract class Tag<T> : TagBase, IRawHtmlString, IHtmlString, IHtmlTag, ITag, IEnumerable<ITag>, IEnumerable where T : Tag<T>
Type Parameters
Constructors
|
Improve this Doc
View Source
Tag(Boolean, String, TagOptions)
Declaration
protected Tag(bool dummyForConstructor, string tagOverride, TagOptions options = null)
Parameters
Type |
Name |
Description |
System.Boolean |
dummyForConstructor |
|
System.String |
tagOverride |
|
TagOptions |
options |
|
|
Improve this Doc
View Source
Tag(String, Object, TagOptions)
Declaration
protected Tag(string name, object content, TagOptions options = null)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.Object |
content |
|
TagOptions |
options |
|
|
Improve this Doc
View Source
Tag(String, TagOptions)
Declaration
protected Tag(string name = null, TagOptions options = null)
Parameters
Type |
Name |
Description |
System.String |
name |
|
TagOptions |
options |
|
|
Improve this Doc
View Source
Tag(String, TagOptions, Object[])
Declaration
protected Tag(string name, TagOptions options, object[] content)
Parameters
Type |
Name |
Description |
System.String |
name |
|
TagOptions |
options |
|
System.Object[] |
content |
|
|
Improve this Doc
View Source
Tag(Tag<T>, CloneChanges)
Special constructor just for cloning with changes
Declaration
protected Tag(Tag<T> original, CloneChanges changes)
Parameters
Type |
Name |
Description |
Tag<T> |
original |
|
ToSic.Razor.Markup.CloneChanges |
changes |
|
Methods
|
Improve this Doc
View Source
Add(Object[])
Add contents to this tag - at the end of the already added contents.
If you want to replace the contents, use Wrap() instead
Declaration
public T Add(params object[] children)
Parameters
Type |
Name |
Description |
System.Object[] |
children |
a variable amount of tags / strings to add to the contents of this tag
|
Returns
|
Improve this Doc
View Source
AsHtmlTag()
Declaration
public IHtmlTag AsHtmlTag()
Returns
|
Improve this Doc
View Source
Attr(Object)
Quickly add an attribute
it always returns the tag itself again, allowing chaining of multiple add-calls
Declaration
public T Attr(object nameWithValue)
Parameters
Type |
Name |
Description |
System.Object |
nameWithValue |
Object which can be ToString()ed
|
Returns
|
Improve this Doc
View Source
Attr(String, Object, String)
Quickly add an attribute
it always returns the tag itself again, allowing chaining of multiple add-calls
Declaration
public T Attr(string name, object value = null, string appendSeparator = null)
Parameters
Type |
Name |
Description |
System.String |
name |
the attribute name, or a complete value like "name='value'"
|
System.Object |
value |
optional value - if the attribute already exists, it will be appended
|
System.String |
appendSeparator |
attribute appendSeparator in case the value is appended
|
Returns
|
Improve this Doc
View Source
Class(String)
Declaration
public T Class(string value)
Parameters
Type |
Name |
Description |
System.String |
value |
|
Returns
|
Improve this Doc
View Source
Data(String, Object)
Declaration
public T Data(string name, object value = null)
Parameters
Type |
Name |
Description |
System.String |
name |
the term behind data-, so "name" becomes "data-name". If empty, will just create a "data" attribute
|
System.Object |
value |
string or object, objects will be json serialized
|
Returns
|
Improve this Doc
View Source
Id(String)
ID - set multiple times always overwrites previous ID
Declaration
Parameters
Type |
Name |
Description |
System.String |
id |
|
Returns
|
Improve this Doc
View Source
On(String, Object)
Add a onEventName attribute for javascript events
Declaration
public T On(string name, object value = null)
Parameters
Type |
Name |
Description |
System.String |
name |
the term behind data-, so "name" becomes "data-name"
|
System.Object |
value |
string or object, objects will be json serialized
|
Returns
|
Improve this Doc
View Source
Style(String)
style attribute. If called multiple times, will append styles.
Declaration
public T Style(string value)
Parameters
Type |
Name |
Description |
System.String |
value |
Style to add
|
Returns
|
Improve this Doc
View Source
Title(String)
Declaration
public T Title(string value)
Parameters
Type |
Name |
Description |
System.String |
value |
new title to set
|
Returns
|
Improve this Doc
View Source
Wrap(Object[])
Wrap the tag around the new content, so this replaces all the content with what you give it
Declaration
public T Wrap(params object[] content)
Parameters
Type |
Name |
Description |
System.Object[] |
content |
a variable amount of tags / strings to add to the contents of this tag
|
Returns
Implements
System.Web.IHtmlString
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable