Forum OpenACS Development: Re: New template tags - switch statement
This is beautiful, thanks.
I only have one suggestion, which would be to move the condition entirely into the <case> par, for improved readability of the templates, like this:
<case @foobar@ true>
<case @baz@ eq "greble">
That would make it easier to read the template, because you don't have to read both the <switch> statement and the <case> statement to find out what's going on.
<if @foobar@ true> ... </if> <elseif @baz@ eq "greble"> ... </elseif> ... <else> ... </else>(and we probably should add an elseif tag).
- You have to mention the variable in every case statement. Despite the fact that this allows a switch for multi variable combinations it does add more code and you have to doublecheck every case statement whether the variable is the same as in the above case statement.
- As a grafik designer I'd see the switch statement, see what variable it concerns and decide quickly whether I'd want to change the code in between. That wouldn't work otherwise. One suggestion would be to have the default behaviour as it is defined right now and add a flag "multiple" to the switch statement with no variable following. This would say that the variables are contained within the case tags as suggested by Lars. We'd just have to encourage people (either by code or by documentation), not to use the multiple functionality if the flag is not set correctly, otherwise you really don't know what might be happening :).