Design issue xf:contentcheck & xf:set interact unexpectedly

Xon

Well-known member
Affected version
2.0.10
Code:
<xf:if contentcheck="true">    
    <xf:set var="$test" value="{{ true }}"/>
    {{ $test ? 'a' : 'b'}}
    <xf:contentcheck>
        {{ $test ? 'a' : 'b'}}
    </xf:contentcheck>
</xf:if>
This outputs "a b", not the expected "a a"
 
I don't really feel like that's unexpected, given the purpose of the code.

It may be slightly unclear, but we have to evaluate the content within the contentcheck tag first, in order to decide whether the rest of it should be rendered.

It essentially looks like this in PHP:
PHP:
$inner = ($test ? 'a' : 'b');
if (strlen(trim($inner)) > 0)
{
    $test = true;
    $finalOutput .= ($test ? 'a' : 'b') ;
    $finalOutput .= $inner;
}
Given this output, there isn't really a way to fix this, so it's a design issue, really.
 
Back
Top Bottom