[DEV-6370] Allow recursive conditionals
If an `lvm:if` is immediately followed by another 'lvm:if`, both should be used to create the conditional. The existing code wouild only "select the nearest condition".master
parent
cbe32aff72
commit
0fadbe8e8a
|
@ -398,7 +398,35 @@
|
|||
<xsl:variable name="cond" as="element( lvmp:condition )"
|
||||
select="ancestor::lvmp:condition[1]" />
|
||||
|
||||
<xsl:text>( ( </xsl:text>
|
||||
<xsl:text>( </xsl:text>
|
||||
|
||||
<xsl:call-template name="conditionals">
|
||||
<xsl:with-param name="cond" select="$cond" />
|
||||
</xsl:call-template>
|
||||
|
||||
<xsl:text> ) ? </xsl:text>
|
||||
|
||||
<xsl:apply-templates mode="lvmp:render">
|
||||
<xsl:with-param name="no-trailing-sep" select="true()" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:text> : null ), </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="conditionals">
|
||||
<xsl:param name="cond"/>
|
||||
|
||||
<!-- if the parent node is also a conditional, it should be joined with this one -->
|
||||
<xsl:if test="$cond/parent::lvmp:condition">
|
||||
<xsl:call-template name="conditionals">
|
||||
<xsl:with-param name="cond" select="$cond/.." />
|
||||
</xsl:call-template>
|
||||
|
||||
<xsl:text>)</xsl:text>
|
||||
<xsl:text> && </xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text>( </xsl:text>
|
||||
<xsl:text>$contract->isTruthy( </xsl:text>
|
||||
<xsl:apply-templates select="$cond/lvmp:when/lvmp:*" mode="lvmp:render" />
|
||||
<xsl:if test="$cond/lvmp:cmp/(*|text())">
|
||||
|
@ -406,15 +434,9 @@
|
|||
<xsl:apply-templates select="$cond/lvmp:cmp/(lvmp:*|text())" mode="lvmp:render" />
|
||||
</xsl:if>
|
||||
<xsl:text>)</xsl:text>
|
||||
<xsl:text> ) ? </xsl:text>
|
||||
<xsl:apply-templates mode="lvmp:render">
|
||||
<xsl:with-param name="no-trailing-sep" select="true()" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:text> : null ), </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<xsl:template mode="lvmp:render" priority="8" match="lvmp:condition[ @when ]">
|
||||
<xsl:variable name="cond" select="." />
|
||||
|
||||
|
|
Loading…
Reference in New Issue