digideskio / zotonic

Automatically exported from code.google.com/p/zotonic
0 stars 0 forks source link

IF statements on empty rsc_list structures #102

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
{% print m.rsc[id].o.related %}

prints {rsc_list,[]}

however: 
{% if m.rsc[id].o.related %}

evaluates to TRUE instead of to false.
this is a regression.

Original issue reported on code.google.com by scherpenisse on 24 Aug 2010 at 7:17

GoogleCodeExporter commented 8 years ago
I can't reproduce this problem:

4> erlydtl:compile(<<"{% if m.rsc[id].o.related %}yep{%else%}nop{%endif%}">>, 
t, z_context:new(default)).
{ok,t}
5> t:render([{id, 1}], z_context:new(default)).
 {ok,[[<<"nop">>]]}                         

Original comment by ma...@pobox.com on 24 Aug 2010 at 7:26

GoogleCodeExporter commented 8 years ago
After further tests the problem turns out to be that the following expression 
evaluates wrongly iff the related list is empty.

{% print m.rsc[id].o.related and 1 %}

Original comment by ma...@pobox.com on 25 Aug 2010 at 11:06

GoogleCodeExporter commented 8 years ago
Added {rsc_list,[]} to z_convert:to_bool/1 as a 'false' value.

Changed behaviour of the string value "false" when converted to a boolean, now 
the string value "false" will evaluate to the boolean value 'false'. Changed 
unit tests accordingly.

Fixed in r98b2541592

Original comment by ma...@pobox.com on 25 Aug 2010 at 12:28