I am trying to use a simple if statement in Twig. However it doesn't seem to be working properly. The variable emailActivation is certainly being loaded into Twig properly as can be seen from the first line of the output in all cases.
However the if statement is behaving very oddly - for example it works as expected when the variable is false and being tested against 1 (case 2) but not when it is false and tested against 'false' (case 1).
Conversely when the variable is true the if statement works when the variable is tested against 'true' (case 3) but not when tested against 1 (case 4).
I only show the tests against 1 as a workaround I attempted, really I think the problem lies in (case 1). (case 5) and (case 4) suggest the numbers are being evaluated as boolean.
I also thought it could perhaps be an issue to do with caching, but to my knowledge I have set Twig up not to use a cache. Even if Twig is caching the problem still occurs on the first page load and when the browser is restarted. I have tried in IE and Firefox though again I don't think the browser is really relevant to the problem which lies in Twig itself as far as I can tell.
Thanks in advance for any assistance!
Case 1 emailActivation = false
Twig code
{{ emailActivation }} {% if emailActivation == true %} feature disabled {% else %} other content {% endif %} Output
false
feature disabled
Case 2 emailActivation = false
Twig code
{{ emailActivation }} {% if emailActivation == 1 %} feature disabled {% else %} other content {% endif %} Output
false
other content
Case 3 emailActivation = true
Twig code
{{ emailActivation }} {% if emailActivation == true %} feature disabled {% else %} other content {% endif %} Output
true
feature disabled
Case 4 emailActivation = true
Twig code
{{ emailActivation }} {% if emailActivation == 1 %} feature disabled {% else %} other content {% endif %} Output
true
other content
Case 5 emailActivation = true
Twig code
{{ emailActivation }} {% if emailActivation == 0 %} feature disabled {% else %} other content {% endif %} Output
true
feature disabled
{{ emailActivation }}[instead of nothing or 1 [or something else] first time i see this]]