Copied to clipboard

Flag this post as spam?

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


  • Brian Olsen 143 posts 424 karma points
    Mar 25, 2013 @ 16:08
    Brian Olsen
    0

    razor to xslt

    This is a Razor script, and I like to make it into Xslt script

             
          if (@strfyld == "column1x1"){strtw = "columnb1";}
          if (@strfyld == "column1x2"){strtw = "columnb2";}
          if (@strfyld == "column2x1"){strtw = "columnb1 columnh2"}
          if (@strfyld == "column2x2"){strtw = "columnb2 columnh2"}
          if (@strfyld == "column2x3"){strtw = "columnb3 columnh2"}
          if (@strfyld == "column2x4"){strtw = "columnb4 columnh2"}

    <div  class="column @strtw paddingrb16"><div class="transition @strfyld"><img class="rundkanter" src="@strdamp"/></div><div class="textoverteasers @strtw"><div class="padding5"><span class="sortlilleoverskrift">@stroverskrift</span><br/><div class="padding10"><span class="teasertext">@strtekst</span></div></div></div></div></a>

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 27, 2013 @ 16:35
    Lee Kelleher
    1

    Hi Brian,

    Here's an example of how to convert the Razor over to XSLT:

    <xsl:variable name="strfyld" select="'not sure where you are getting this value from?'" />
    <xsl:variable name="strtw">
        <xsl:choose>
            <xsl:when test="$strfyld = 'column1x1'">columnb1</xsl:when>
            <xsl:when test="$strfyld = 'column1x2'">columnb2</xsl:when>
            <xsl:when test="$strfyld = 'column2x1'">columnb1 columnh2</xsl:when>
            <xsl:when test="$strfyld = 'column2x2'">columnb2 columnh2</xsl:when>
            <xsl:when test="$strfyld = 'column2x3'">columnb3 columnh2</xsl:when>
            <xsl:when test="$strfyld = 'column2x4'">columnb4 columnh2</xsl:when>
        </xsl:choose>
    </xsl:variable>
    <div  class="column {$strtw} paddingrb16">
        <div class="transition {$strfyld}">
            <img class="rundkanter" src="{$strdamp}"/>
        </div>
        <div class="textoverteasers {$strtw}">
            <div class="padding5">
                <span class="sortlilleoverskrift">
                    <xsl:value-of select="$stroverskrift"/>
                </span>
                <br/>
                <div class="padding10">
                    <span class="teasertext">
                        <xsl:value-of select="$strtekst"/>
                    </span>
                </div>
            </div>
        </div>
    </div>

    Obviously from your original code snippet, I'm not sure where the values come from for the variables: "strfyld", "strdamp", "stroverskrift" and "strtekst" - you'll need to populate those.

    Cheers, Lee.

Please Sign in or register to post replies

Write your reply to:

Draft