Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • bh 163 posts 524 karma points
    1 week ago
    bh
    0

    v8 RemoveFirstParagraphTag

    I've been using @Html.Raw(umbraco.library.RemoveFirstParagraphTag(Model.GetPropertyValue("homeNewsPerspectiveTitle").ToString()))

    what's the v8 version of that? umbraco.library.RemoveFirstParagraphTag doesn't seem to exist, or if it does I haven't found it yet.

  • Thomsen 64 posts 234 karma points
    1 week ago
    Thomsen
    0

    The whole umbraco.library has been obsolete for years and has now been removed from v8 as a part of the "code cleanup".

    Though, the RemoveFirstParagraphTag method was nice and should be requested re-invoked ...

  • bh 163 posts 524 karma points
    1 week ago
    bh
    0

    Does anyone have a alternative for the deprecated RemoveFirstParagraphTag? I use that method extensively throughout my projects.

  • Marc Goodson 786 posts 5196 karma points MVP 3x c-trib
    1 week ago
    Marc Goodson
    0

    Hi bh

    The implementation for it was like so:

     public static string RemoveFirstParagraphTag(string text)
            {
                if (String.IsNullOrEmpty(text))
                    return "";
    
                if (text.Length > 5)
                {
                    if (text.ToUpper().Substring(0, 3) == "<P>")
                        text = text.Substring(3, text.Length - 3);
                    if (text.ToUpper().Substring(text.Length - 4, 4) == "</P>")
                        text = text.Substring(0, text.Length - 4);
                }
                return text;
            }
    

    so you could add an extension method or service to do the same logic in your new projects.

    https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/umbraco.presentation/library.cs

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft