Rendering html as a string in RazorLight

471 Views Asked by At

I want to render a string so that if the string includes a "br" tag, it doesn't break the line and show br tag as text:

    public RazorLight.Text.RawString PrintValueOrEmpty()
    {
        if (Value == null)
        {
            return new RazorLight.Text.RawString(string.Empty);
        }

        var html = $@"<p class=""text-row"">{Value}</p>";
        return new RazorLight.Text.RawString(html);
    }

And when I use PrintValueOrEmpty() in cshtml and when a string contains a br tag, it breaks the line which I don't want

<td>@Model.GeneralInformation.Comment.PrintValueOrEmpty()</td>
0

There are 0 best solutions below