2

I am trying to build a switch/case structure around a range of integer values. As stated in the language reference, if the case expression is the symbol default, it always matches the switch. However, I am looking for a symbol that matches in all cases except for the ones listed above the symbol...

<ul tal:switch="i">
  <li tal:case="1">one</li>
  <li tal:case="2">two</li>
  <li tal:case="default">not one or two</li>
</ul>

I have tried the otherwise symbol, but it doesn't work either.

malthe
  • 1,237
  • 13
  • 25
Fynn
  • 4,753
  • 3
  • 32
  • 69

2 Answers2

3

True. There's no sense in the docs, because "default" will always match. It's a bug!

Please someone report it on the Github tracker.

malthe
  • 1,237
  • 13
  • 25
  • This has now been fixed. Note that as a consequence, only a single ``tal:case`` can now succeed. – malthe Mar 05 '13 at 11:01
0

I'm fairly certain the symbol needs to be in the namespaced case statement or the parser will just ignore the symbol you put in there.

<ul tal:switch="i">
  <li tal:case="1">one</li>
  <li tal:case="2">two</li>
  <li tal:case="default">not one or two</li>
</ul>
Michael Merickel
  • 23,153
  • 3
  • 54
  • 70
  • I think that's the correct syntax. As I mess with it I can't seem to get default to work either for any sense of the term "default". This might just be a bug in Chameleon. – Michael Merickel Nov 23 '11 at 08:14