Copied to clipboard

Flag this post as spam?

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


  • Thomas Kahn 602 posts 506 karma points
    Nov 13, 2012 @ 14:07
    Thomas Kahn
    0

    umbraco.library:ReplaceLineBreaks doesn't seem to work?

    Hi!

    I'm trying to convert line breaks that the administrator has entered into a multiple textbox. I need this to be done in my XSLT. Here's my code:

    <xsl:value-of select="umbraco.library:ReplaceLineBreaks($currentPage/textStartPage)" />
    

    I know that there is a valid text value with line breaks in $currentPage/textStartPage since the text is printed to the page. And the line breaks are visible when I view the HTML source code but since no HTML tags are generated using the above code I get one long text withour line breaks.

    I'm using umbraco v 4.9.0 (Assembly version: 1.0.4633.18696).

    Regards,
    Thomas

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Nov 24, 2012 @ 02:39
    Lee Kelleher
    0

    Hi Thomas,

    Just on the off-chance, are you using a Mac (OS X) to edit your content?

    The reason I ask is that I know that the "ReplaceLineBreaks" function does a string replace on the "\n" control character (swapping it out for a "<br/>"), but I believe on the Mac a newline is an "\r" character.  Are you able to edit the content from a Windows machine?

    I could be completely wrong about this... but seeing as no one else had replied, I thought it might help?

    Thanks, Lee.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Nov 24, 2012 @ 23:36
    Chriztian Steinmeier
    1

    Hi Thomas,

    Are you by any chance seeing some weird characters/content where the linebreaks were supposed to be? (e.g.: &lt;br/&gt;)

    The value-of instruction can only return a string of text, which will make any HTML content come out as escaped. You can try to add a flag to the instruction to disable this:

    <xsl:value-of select="umbraco.library:ReplaceLineBreaks($currentPage/textStartPage)" disable-output-escaping="yes" />

    The \n vs. \r thing ideally shouldn't be a problem, as one of the beatiful things of using XML is that all linefeeds must be normalized initially by the parser, so regardless of platform they should all end up as the character &#10; when the file is parsed and ready for use, e.g., with XSLT.

    /Chriztian

  • keilo 568 posts 1023 karma points
    Sep 29, 2014 @ 12:11
    keilo
    0

    Hi Chriztian

    I came across this on a legacy system supported and that last attribute did the trick indeed. Without it it return &lt; and &gt.

    This was after adding the suggested template code at http://our.umbraco.org/forum/umbraco-pro/contour/18103-Send-xslt-transformed-email-Here-is-my-xslt-email-template

    without any changes. Not sure why it worked for other in that forum post as no one seems to complained about it...

    Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft