diff options
author | Joseph Frazer <joseph.frazer@ryansg.com> | 2019-10-25 08:04:21 -0400 |
---|---|---|
committer | Joseph Frazer <joseph.frazer@ryansg.com> | 2019-11-01 10:23:19 -0400 |
commit | 0fadbe8e8ae905f2bed74bda5d49bbfcb59f8db9 (patch) | |
tree | 15d59699672292df363ae7e3c2a4ac245729ebf0 /src | |
parent | cbe32aff72a2da7416befd6588f9921ff7e53aa6 (diff) | |
download | tame-0fadbe8e8ae905f2bed74bda5d49bbfcb59f8db9.tar.gz tame-0fadbe8e8ae905f2bed74bda5d49bbfcb59f8db9.tar.bz2 tame-0fadbe8e8ae905f2bed74bda5d49bbfcb59f8db9.zip |
[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".
Diffstat (limited to 'src')
-rw-r--r-- | src/current/c1map/render.xsl | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/current/c1map/render.xsl b/src/current/c1map/render.xsl index a7f5cc9..1689a67 100644 --- a/src/current/c1map/render.xsl +++ b/src/current/c1map/render.xsl @@ -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="." /> |