gobuffalo / plush

The powerful template system that Go needs
MIT License
901 stars 56 forks source link

if (variable == false){} doesn't work.Only == true #110

Closed AlexTselikas closed 3 years ago

AlexTselikas commented 4 years ago

Hello, I am using version v3.8.3 and i have this problem. If i use:

<%= if (variable == false) {%>
        disabled
<%}%>

it doesn't work. I have to use this:

<%= if (variant.VariantTrackQuantity ==true) {%>

<%} else {%>
        disabled
<%}%>

It doesn't display an error message, it just doesn't write the HTML.If i use variable == true it works.

adam-buckley commented 4 years ago

I'm on v3.8.3 and I can use == false with no problems. With the info you've given, I think this can only mean that the value of the variable that you are testing is actually true, not false. You can test that == false is indeed working by setting a variable to false in your template and testing if it's false:

<%
let test = false
%>
<%= if (test == false) { %>
<p>The test was false</p>
<% } %>

I hope this helps. Adam

Mido-sys commented 3 years ago

@adam-buckley,

This pull request should fix the issue.