Interface IScrub
IScrub helps wash/clean html from things you want removed. It can take care of all tags, just specific tags or certain attributes.
Note that it is implemented as an interface, so you must use Dependency Injection to get it.
Namespace: ToSic.Razor.Blade
Assembly: ToSic.Razor.dll
Syntax
public interface IScrub
Remarks
Added in v3.9
Methods
| Improve this Doc View SourceAll(String)
Remove all HTML tags from a string.
Declaration
string All(string html)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | html | Original HTML |
Returns
| Type | Description |
|---|---|
| System.String | A cleaned string without any HTML tags |
Attributes(String)
Remove all HTML attributes.
Declaration
string Attributes(string html)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | html | Original HTML |
Returns
| Type | Description |
|---|---|
| System.String | A string without any attributes inside the HTML Tags |
Attributes(String, String)
Remove all instances of a specified attribute.
Declaration
string Attributes(string html, string attribute)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | html | Original HTML |
| System.String | attribute | string defining the attribute to remove |
Returns
| Type | Description |
|---|---|
| System.String | A string which doesn't contain the specified attribute |
Attributes(String, String[])
Remove all instances of an array of specified attributes.
Declaration
string Attributes(string html, params string[] attributes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | html | Original HTML |
| System.String[] | attributes | array defining the attributes to remove |
Returns
| Type | Description |
|---|---|
| System.String | A string which doesn't contain the specified attributes |
Classes(String)
Remove all class attributes
Declaration
string Classes(string html)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | html | Original HTML |
Returns
| Type | Description |
|---|---|
| System.String | A string without any class=""/class=''/class= attributes |
Except(String, String[])
Remove all HTML Tags except of a specified list
Declaration
string Except(string html, params string[] tags)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | html | Original HTML |
| System.String[] | tags | array defining the HTML Tags which shouldn't be removed |
Returns
| Type | Description |
|---|---|
| System.String | A string which doesn't contain the specified HTML Tags |
Only(String, String)
Remove one specific HTML tag from a string.
Declaration
string Only(string html, string tag)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | html | Original HTML |
| System.String | tag | tag name to remove |
Returns
| Type | Description |
|---|---|
| System.String |
Only(String, String[])
Remove many specific HTML tags from a string.
Declaration
string Only(string html, params string[] tags)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | html | Original HTML |
| System.String[] | tags | one or more tags to remove |
Returns
| Type | Description |
|---|---|
| System.String |
Styles(String)
Remove all style attributes
Declaration
string Styles(string html)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | html | Original HTML |
Returns
| Type | Description |
|---|---|
| System.String | A string without any style=""/style=''/style= attributes |