creationix / haml-js

Haml ported to server-side Javascript. This is a traditional server-side templating language. Tested with node-js
MIT License
902 stars 110 forks source link

Bugfix regaring :else #72

Closed brakhane closed 11 years ago

brakhane commented 11 years ago

:else is implemented via "if ! condition", so in the following expression:

:if 1+1==3 ... :else ...

the else part is compiled into "if ! 1+1 == 3". Since in JavaScript, the not operator has higher precedence, this is interpreted as "if (!1)+1 == 3", which is false. Therefore, the above expression will output nothing unless the condition would have been written as ":if (1+1==3)"

This commit fixes :else and :elseif by always adding parenthesis like it is done for if.