Skip to content

Commit 05ab8a2

Browse files
authored
Merge pull request #6953 from umbraco/cms/fix-reference-to-rich-text-type
Fixed reference to typed value when rendering rich text property values
2 parents a8027da + 3841467 commit 05ab8a2

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

10/umbraco-cms/fundamentals/design/rendering-content.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,21 @@ Each property in your [Document Type](../data/defining-content/#what-is-a-docume
1919

2020
### Specifying types of data
2121

22-
You can specify the type of data being returned to help you format the value for display, consider the publish date in our example:
22+
You can specify the type of data being returned to help you format the value for display.
2323

24-
To use the `<IHtmlContent>` as the data return type, add the `@using Microsoft.AspNetCore.Html;` directive.
24+
In our example, we have a string, a date and some rich text:
2525

2626
```html
2727
<h1>@(Model.Value<string>("pageTitle"))</h1>
28-
<div>@(Model.Value<IHtmlContent>("bodyContent"))</div>
28+
<div>@(Model.Value<IHtmlEncodedString>("bodyContent"))</div>
2929
<p>Article date: <time>@(Model.Value<DateTime>("articleDate").ToString("dd/MM/yyyy"))</time></p>
3030
```
3131

32+
{% hint style="info" %}
33+
To use `IHtmlEncodedString` as the typed value, add the `@using Umbraco.Cms.Core.Strings;` directive.
34+
{% endhint %}
35+
36+
3237
### Using ModelsBuilder
3338

3439
```html

13/umbraco-cms/fundamentals/design/rendering-content.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ Each property in your [Document Type](../data/defining-content/#what-is-a-docume
1414

1515
### Specifying types of data
1616

17-
You can specify the type of data being returned to help you format the value for display, consider the publish date in our example:
17+
You can specify the type of data being returned to help you format the value for display.
1818

19-
To use the `<IHtmlContent>` as the data return type, add the `@using Microsoft.AspNetCore.Html;` directive.
19+
In our example, we have a string, a date and some rich text:
2020

2121
```html
2222
<h1>@(Model.Value<string>("pageTitle"))</h1>
23-
<div>@(Model.Value<IHtmlContent>("bodyContent"))</div>
23+
<div>@(Model.Value<IHtmlEncodedString>("bodyContent"))</div>
2424
<p>Article date: <time>@(Model.Value<DateTime>("articleDate").ToString("dd/MM/yyyy"))</time></p>
2525
```
2626

27+
{% hint style="info" %}
28+
To use `IHtmlEncodedString` as the typed value, add the `@using Umbraco.Cms.Core.Strings;` directive.
29+
{% endhint %}
30+
2731
### Using ModelsBuilder
2832

2933
```html

14/umbraco-cms/fundamentals/design/rendering-content.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ Each property in your [Document Type](../data/defining-content/#what-is-a-docume
1414

1515
### Specifying types of data
1616

17-
You can specify the type of data being returned to help you format the value for display, consider the publish date in our example:
17+
You can specify the type of data being returned to help you format the value for display.
1818

19-
To use the `<IHtmlContent>` as the data return type, add the `@using Microsoft.AspNetCore.Html;` directive.
19+
In our example, we have a string, a date and some rich text:
2020

2121
```html
2222
<h1>@(Model.Value<string>("pageTitle"))</h1>
23-
<div>@(Model.Value<IHtmlContent>("bodyContent"))</div>
23+
<div>@(Model.Value<IHtmlEncodedString>("bodyContent"))</div>
2424
<p>Article date: <time>@(Model.Value<DateTime>("articleDate").ToString("dd/MM/yyyy"))</time></p>
2525
```
2626

27+
{% hint style="info" %}
28+
To use `IHtmlEncodedString` as the typed value, add the `@using Umbraco.Cms.Core.Strings;` directive.
29+
{% endhint %}
30+
2731
### Using ModelsBuilder
2832

2933
```html

15/umbraco-cms/fundamentals/design/rendering-content.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ Each property in your [Document Type](../data/defining-content/#what-is-a-docume
1414

1515
### Specifying types of data
1616

17-
You can specify the type of data being returned to help you format the value for display, consider the publish date in our example:
17+
You can specify the type of data being returned to help you format the value for display.
1818

19-
To use the `<IHtmlContent>` as the data return type, add the `@using Microsoft.AspNetCore.Html;` directive.
19+
In our example, we have a string, a date and some rich text:
2020

2121
```html
2222
<h1>@(Model.Value<string>("pageTitle"))</h1>
23-
<div>@(Model.Value<IHtmlContent>("bodyContent"))</div>
23+
<div>@(Model.Value<IHtmlEncodedString>("bodyContent"))</div>
2424
<p>Article date: <time>@(Model.Value<DateTime>("articleDate").ToString("dd/MM/yyyy"))</time></p>
2525
```
2626

27+
{% hint style="info" %}
28+
To use `IHtmlEncodedString` as the typed value, add the `@using Umbraco.Cms.Core.Strings;` directive.
29+
{% endhint %}
30+
2731
### Using ModelsBuilder
2832

2933
```html

0 commit comments

Comments
 (0)