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.

有帮助吗?

解决方案

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.

其他提示

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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top