Closed artemipanchuk closed 7 years ago
Yes, good catch, thank you. It is a bug. I am working on a fix. I'll let you know...
Here is a patched version. Let me know whether it works correctly for you... Thanks... jsviews.js.txt
Seems like an operator precedence problem. If you do {^{if (~t) && (~t^length>0)}}
, it works.
Thanks for your quick response. Looking forward to see new release with these fixes.
@gbouthenot: It is actually a bug. The array returned by ~t was not getting data-linked for array changes, so the ~t^length was not updating from 0 to 1 when an item was inserted into the array.
@artemipanchuk: The fix (jsviews.js.txt) did work for your environment, right?
@BorisMoore sure, your fix worked in my case too. This issue can be closed after new release.
Good. I'll include it in the next update...
Resolved in commit 88
Please, take a look at following fiddle: https://jsfiddle.net/nq4372t8/26/
There, as you can see, are 4 different "ways" to describe logic of checking some value.
First two ways do
~t=item
, and second two ways do~t=getItem()
. 1-st and 3-rd ways are checking result in variable with oneif
tag, as{^{if ~t && ~t^length>0}} ...
. 2-nd and 4-th ways are checking result in variable with twoif
tags, as{^{if ~t}} {^{if ~t^length>0}} ...
.The question is: why does jsrender conider result of
{^{if ~t && ~t^length>0}}
asfalse
in 3-rd example? We think, it is similar to other examples. Is it correct? If it is, then what point do we miss?Thanks.