U4-10029 - Umbraco.ReplaceLineBreaksForHtml should return an IHtmlString

Created by Søren Kottal 16 Jun 2017, 18:57:48 Updated by Sebastiaan Janssen 31 Aug 2018, 17:36:36

Tags: PR

In my head it doesn't really make sense that a method for creating html, doesn't return html.

This means, that right now we have to do @Html.Raw(Umbraco.ReplaceLineBreaksForHtml(Model.BodyText)) to get html in our views.

Comments

Søren Kottal 16 Jun 2017, 19:15:54

PR https://github.com/umbraco/Umbraco-CMS/pull/2005/


Søren Gregersen 27 Aug 2017, 19:49:14

@sebastiaan @Søren.Kottal does it really makes sense to have all those ReplaceLineBreaksForHtml, StripHtml, Concatenate etc methods on UmbracoHelper?

The was I see it, UmbracoHelper helps to get access to umbraco (content/media etc). All the other methods feel like they should live as static methods or extension-methods on Url/Html-helper - at least that feels more natural for an Asp.Net Mvc-developer.


Søren Kottal 27 Aug 2017, 20:06:56

I agree, IMO it should be an extension method (string.ReplaceLineBreaksForHtml), and then also add a string.AutoAddParagraphs (like wordpress' wpautop function).


Søren Gregersen 28 Aug 2017, 04:33:34

I think it's natural that an extension-merhod on String should return string, not (I)HtmlString. It feels off to me.

HtmlHelper.ReplaceNewlinesWithBreaks(string html) could/should do the trick.

In angular we also need special handling, when a string containing html is being bound.


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: False

Fix Submitted: Pull request

Affected versions:

Due in version: 8.0.0

Sprint:

Story Points:

Cycle: