Class AttributeOptions
Configure how attributes will be serialized. It's a read-only object to ensure fluid APIs. Properties cannot be modified. To modify a property, create a new one to clone the settings of the previous.
Inheritance
Namespace: ToSic.Razor.Markup
Assembly: ToSic.Razor.dll
Syntax
public class AttributeOptions
Remarks
In v4.0 it was changed to be read-only for reliably fluid APIs.
Constructors
| Improve this Doc View SourceAttributeOptions(AttributeOptions, String, Nullable<Boolean>, Nullable<Boolean>, Nullable<Boolean>)
Declaration
public AttributeOptions(AttributeOptions original = null, string quote = null, bool? encodeQuotes = null, bool? keepEmpty = null, bool? dropValueIfNull = null)
Parameters
Type | Name | Description |
---|---|---|
AttributeOptions | original | |
System.String | quote | |
System.Nullable<System.Boolean> | encodeQuotes | |
System.Nullable<System.Boolean> | keepEmpty | |
System.Nullable<System.Boolean> | dropValueIfNull |
Fields
| Improve this Doc View SourceDefaultDropValueIfNull
By default a null-value will result in an attribute-name only.
Declaration
public const bool DefaultDropValueIfNull = true
Field Value
Type | Description |
---|---|
System.Boolean |
DefaultEncodeQuotes
By default quotes will not be encoded if this results in valid html.
Declaration
public const bool DefaultEncodeQuotes = false
Field Value
Type | Description |
---|---|
System.Boolean |
DefaultKeepEmpty
By default, empty attributes are preserved.
Declaration
public const bool DefaultKeepEmpty = true
Field Value
Type | Description |
---|---|
System.Boolean |
DefaultQuote
By default, use the '
quote for attributes since it allows for storing json in attributes which is fairly common.
Declaration
public const string DefaultQuote = "'"
Field Value
Type | Description |
---|---|
System.String |
Properties
| Improve this Doc View SourceDropValueIfNull
Drop the value part of the attribute if the value would be null.
When true, name=null
will result in name
- when false it will be name=''
Declaration
public bool DropValueIfNull { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
EncodeQuotes
Encode quotes or apostrophes in attributes which clearly don't need encoding
Declaration
public bool EncodeQuotes { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
KeepEmpty
Place empty attributes on the tag anyhow.
Declaration
public bool KeepEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Quote
What character is used for wrapping attribute values
Declaration
public string Quote { get; }
Property Value
Type | Description |
---|---|
System.String |