-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,15 +36,7 @@ else | |
<govuk-summary-list-row-value data-testid="[email protected]"> | ||
@if (!string.IsNullOrEmpty(@alert.Details)) | ||
{ | ||
var lines = @alert.Details.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); | ||
@for (int i = 0; i < lines.Length; i++) | ||
{ | ||
<span>@lines[i]</span> | ||
@if (i < lines.Length - 1) | ||
{ | ||
<br /> | ||
} | ||
} | ||
<multi-line-text text="@alert.Details" /> | ||
} | ||
</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
|
31 changes: 31 additions & 0 deletions
31
TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TagHelpers/MultiLineTextTagHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Text.Encodings.Web; | ||
using Microsoft.AspNetCore.Mvc.TagHelpers; | ||
using Microsoft.AspNetCore.Razor.TagHelpers; | ||
|
||
namespace TeachingRecordSystem.SupportUi.TagHelpers; | ||
|
||
public class MultiLineTextTagHelper : TagHelper | ||
{ | ||
public string Text { get; set; } = string.Empty; | ||
|
||
public override void Process(TagHelperContext context, TagHelperOutput output) | ||
{ | ||
output.TagName = "p"; | ||
output.AddClass("govuk-body", HtmlEncoder.Default); | ||
|
||
if (!string.IsNullOrWhiteSpace(Text)) | ||
{ | ||
var lines = Text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); | ||
for (var i = 0; i < lines.Length; i++) | ||
{ | ||
output.Content.Append(lines[i]); | ||
if (i < lines.Length - 1) | ||
{ | ||
output.Content.AppendHtml("<br />"); | ||
} | ||
} | ||
} | ||
|
||
output.TagMode = TagMode.StartTagAndEndTag; | ||
} | ||
} |