Copied to clipboard

Flag this post as spam?

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


  • Blake Watt (Clerke) 106 posts 351 karma points MVP 2x
    Apr 08, 2014 @ 22:47
    Blake Watt (Clerke)
    0

    convert line breaks in 7

    I'm sorry I know this is going to be a dumb question but I'm having trouble finding documentation on this. ive got a simple foreach running through items and I have a textbox multiple that I want to convert line breaks for each item.

    In version 4 I would write @umbraco.library.ReplaceLineBreaks(item.alias) and it would work. That way isn't working anymore. I know that there is something like Umbrao.Field("alias", convertLineBreaks: true) but I'm not getting it. I'll post my code, if anyone could help I'd appreciate it. Thank you bunches!

    the the content i have in the textbox multiple is literally just a string of text and I hit enter and wrote another line. there is no markup in these currently.

    @{
        var items = CurrentPage.Testimonial;
        
        if(items.Count() > 0)
        {
            <div class="quotes">
                @foreach(var item in items)
                {
                    <div class="testimonial">
                        <p class="quote">@item.quote</p>
                        <p class="quoter">@item.quoter</p>
                    </div>
                }
            </div>
        }
    }

     

    Thank you!

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 08, 2014 @ 23:34
    Jan Skovgaard
    100

    Hi Blake

    Perhaps the example shown, which is also marked as solution, in this post helps? http://our.umbraco.org/forum/developers/razor/39891-ReplaceLineBreaks-in-Razor?p=0#comment145788

    Hope this helps.

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 08, 2014 @ 23:34
  • Blake Watt (Clerke) 106 posts 351 karma points MVP 2x
    Apr 08, 2014 @ 23:40
    Blake Watt (Clerke)
    1

    Thanks Jan!

    I don't know what was happening but it's working now. I did however finally find documentation on UmbracoHelper for .ReplaceLineBreaksForHtml(string text) which also works :) Thanks for your help!!! 

     

Please Sign in or register to post replies

Write your reply to:

Draft