Class HtmlStringUtilities
Provides utility methods for UmbracoHelper for working with strings and HTML in views.
Inheritance
System.Object
Namespace: Umbraco.Web
Assembly: Umbraco.Web.dll
Syntax
public sealed class HtmlStringUtilities
Methods
View SourceReplaceLineBreaks(String)
HTML encodes the text and replaces text line breaks with HTML line breaks.
Declaration
public IHtmlString ReplaceLineBreaks(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text. |
Returns
Type | Description |
---|---|
System.Web.IHtmlString | The HTML encoded text with text line breaks replaced with HTML line breaks ( |
ReplaceLineBreaksForHtml(String)
Replaces text line breaks with HTML line breaks.
Declaration
[Obsolete("This method doesn't HTML encode the text. Use ReplaceLineBreaks instead.")]
public HtmlString ReplaceLineBreaksForHtml(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text. |
Returns
Type | Description |
---|---|
System.Web.HtmlString | The text with text line breaks replaced with HTML line breaks ( |
StripHtmlTags(String, String[])
Declaration
public HtmlString StripHtmlTags(string html, params string[] tags)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | |
System.String[] | tags |
Returns
Type | Description |
---|---|
System.Web.HtmlString |
Truncate(String, Int32, Boolean, Boolean)
Declaration
public IHtmlString Truncate(string html, int length, bool addElipsis, bool treatTagsAsContent)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | |
System.Int32 | length | |
System.Boolean | addElipsis | |
System.Boolean | treatTagsAsContent |
Returns
Type | Description |
---|---|
System.Web.IHtmlString |
WordsToLength(String, Int32)
Returns the length of the words from a HTML block
Declaration
public int WordsToLength(string html, int words)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | HTML text |
System.Int32 | words | Amount of words you would like to measure |
Returns
Type | Description |
---|---|
System.Int32 |