Forum OpenACS Q&A: Dynamic "in"-list within <case> tags ...

Does someone know if there's a way to accomplish the following, but with a dynamic list in the "in" clause?


  <switch @state@>
    <case in "authored" "published" "archived">
      <p>State = @state@
    </case>
    <default>
      <p>State unknown.
    </default>
  </switch>

I have tried with the following methods but neither of them works:

.tcl:
set states_list [list authored published archived]

.adp:
<case in @states_list@> .....

and this:

.adp:
<case in <list name="states_list">@states_list:item@ </list>> .....

Thanks.

Hmm, that would be nice. I ran into a similar problem with the 'in' word in the if tag. I ended up creating a new word 'inlist', because the 'in' word used a regexp on the whole list as one word. I made the proposal, but noone commented either way on if that should be added.

I don't think anyone would expect "dog in theory dogma" to return true so that sounds like a good change to make.  I don't know that the old broken behavior needs to be preserved...

Maybe a new 'inreg' or something to indicate that a regular expression match is being used? In the 'if' tag, I once relied on the regular expression to match for row numbers ending in 25/50/75.

What should be supported is to set a list var in the tcl page and use this as you would expect in an 'if' or 'case' tag.

Check out this thread, and this test page.