ariatemplates / hashspace

JavaScript client-side template engine
http://hashspace.ariatemplates.com
Apache License 2.0
14 stars 18 forks source link

Expressions parsing: wrong priority for the ! operator #324

Closed divdavem closed 9 years ago

divdavem commented 9 years ago

Issue

The !myFunction() expression is (wrongly) parsed as if there were parentheses like this: (!myFunction)(), whereas it should be interpreted like this: !(myFunction()) (as it is done in JavaScript). When adding explicit parentheses, the expression is correctly interpreted.

HSP file

<script>
var myFunction = function() {
      return false;
};
</script>

<template myTemplate()>
    {if !myFunction()}
        OK
    {/if}
</template>

<script>
exports.template = myTemplate;
</script>

Plunk

Here is a plunk to reproduce this issue: http://embed.plnkr.co/IqqSQ1FEUuVHici20QMm

The following message is displayed on the console:

[warning] Error evaluating expression '!myFunction()': undefined is not a function 

Hashspace version

Tested with version fbcc30530129b8e57e466926d4dd88cd251043d1.