[Bug-ish] Conditional shortcut should surface broken filter syntax (better)

  <% if [<set-img-list>is[variable] %>
    <!-- always "true" -->
    <!-- no error reported anywhere I can find -->
  <% endif %>

@jeremyruston Worth a bug report?

Hi @CodaCoder the code above is equivalent to this:

<$list filter="[<set-img-list>is[variable]">
    <!-- always "true" -->
    <!-- no error reported anywhere I can find -->
</$list>

Thereā€™s clearly a syntax error in the filter expression, but if you try that filter expression in the $:/AdvancedSearch ā€œfilterā€ tab you will see the error Filter error: Missing [ in filter expression.

The problem is that the error message is returned as the result of the filter expression. That means that the <%if%> statement will always see the expression as returning a result, and thus classify it as ā€œtrueā€.

The deeper problem is that there isnā€™t another obvious way to report syntax errors in filters.

List last N filter errors in (new) More-tab tab?

Crazy brain-fart?

@CodaCoder a reasonable workaround when trying to debug the ā€œIf codeā€, is to display the filters result with the condition variable.

  <% if [<set-img-list>is[variable] %>
    <!-- always "true" --> <<condition>>
    <!-- no error reported anywhere I can find -->
  <% endif %>
  • and you will see Filter error: Missing [ in filter expression

In this example I changed each filter to test the different places

<% if [[a]match[b]] %>
  Loaded from a file URI #1 <<condition>>
<% elseif [[b]match[c]] %>
  Loaded from an HTTPS URI #2 <<condition>>
<% elseif [[c]match[d]] %>
  Loaded from an HTTP URI  #3 <<condition>>
<% else %>
  Loaded from an unknown protocol #4 <<condition>>
<% endif %>
  • Only #4 does not have access to the <<condition>> value. that is the else.
  • it is always available after a filter is used, in if/elseif

Another trick I have being using in functions in the if and elseif filters, it is then possible to just use the variable to see its result.

\function my.filter() [[true]!match[true]

!!<<my. Filter>>

  <% if [my.filter[]] %>
    <!-- always "true" --> here
    <!-- no error reported anywhere I can find -->
  <% endif %>

If you think about it this problem occurs in a number of places where you donā€™t get to see the filters result.

[Post script]
You could even test for the error condtion

\function my.filter() [[true]!match[true]
!!<<my.filter>>

  <% if [my.filter[]prefix[Filter error:]] %>
    <!-- always "true" --> Error condition ''<<condition>>''
    <!-- no error reported anywhere I can find -->
  <% endif %>
1 Like

Bingo. Thanks. ā€ƒ