Copied to clipboard

Flag this post as spam?

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


  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Sep 21, 2012 @ 11:49
    Bjarne Fyrstenborg
    0

    Simple editor - content without linebreaks

    Hi..

    I use the Simple Editor to write content, which can be used in Google Maps info window..

    I store the content in a variable in the template and use that variable in my javascript code.. but the problem is that even if I convert linebreaks with <br /> it still break the line in the source code, which break the javascript code..

    Content in Simple editor:

    <p>Address<br/>Zip City<br/>Tlf: 12 34 56 78<br/><a href="mailto:[email protected]">[email protected]</a>
    </p>

    In template:

    <script type="text/javascript">
    var getDrivingDirections = "<%= umbraco.library.GetDictionaryItem("gmGetDrivingDirections") %>";
    var mapInfoWindowTitle = '<umbraco:Item field="googleMapsInfoWindowTitle" recursive="true" runat="server" />';
    var mapInfoWindowDesc = '<umbraco:Item field="googleMapsInfoWindowDesc" recursive="true" convertLineBreaks="true" runat="server" />';
    </script>

    When I don't use any linebreaks in the editor it works..

    Is the a way to force the content always to display in one line/a string?

    /Bjarne

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Sep 21, 2012 @ 13:33
    Bjarne Fyrstenborg
    0

    Okay.. I moved the variables to a xslt files.. and use normalize-space to remove the linebreaks after I read this post: http://our.umbraco.org/forum/developers/xslt/29290-Remove-line-breaks-for-locator-package

    <xsl:variable name="mapVariable" select="$currentPage/ancestor-or-self::Lang" />
    
    <xsl:text disable-output-escaping="yes">
    &lt;script type="text/javascript"&gt;
    </xsl:text>
        var getDrivingDirections = '<xsl:value-of select="umbraco.library:GetDictionaryItem('gmGetDrivingDirections')" disable-output-escaping="yes"/>';
        var mapInfoWindowTitle = '<xsl:value-of select="umbraco.library:Replace(normalize-space($mapVariable/googleMapsInfoWindowTitle), '&#x0A;', '\n')" disable-output-escaping="yes"/>';
        var mapInfoWindowDesc = '<xsl:value-of select="umbraco.library:Replace(normalize-space($mapVariable/googleMapsInfoWindowDesc), '&#x0A;', '')" disable-output-escaping="yes"/>';
    <xsl:text disable-output-escaping="yes">
    &lt;/script&gt;
    </xsl:text>

    /Bjarne

Please Sign in or register to post replies

Write your reply to:

Draft