Copied to clipboard

Flag this post as spam?

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


  • Gordon Saxby 1461 posts 1883 karma points
    Mar 07, 2011 @ 11:39
    Gordon Saxby
    0

    Conditionally write parts of HTML

    Using Umbraco 4.6.1 / new schema

    I have a situation where I need to write either "<div ...>" or "</div>" depending on a variable (node count / position). If I just put in a couple of IF statements I get an error saying the tag has not been closed. So, is there a "trick" way of doing what I need?

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 07, 2011 @ 11:46
    Kim Andersen
    2

    Hola Gordon

    You might want to try using the CDATA escaping like this:

    <xsl:text disable-output-escaping="yes"><![CDATA[<div>]]></xsl:text>

    <xsl:text disable-output-escaping="yes"><![CDATA[</div>]]></xsl:text>

    Then you shouldn't get any errors when rendering the code.

    /Kim A

  • Gordon Saxby 1461 posts 1883 karma points
    Mar 07, 2011 @ 12:03
    Gordon Saxby
    0

    Thanks Kim - that seems to be working great!

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 07, 2011 @ 18:40
    Jan Skovgaard
    0

    Hi Gordon

    You could also use an empty <xsl:comment /> or even change the output from XML to HTML. But perhaps using the <xsl:comment /> trick is more safe since changing the output to HTML could potentially break other things in the code dependent on the context.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft