Issue Feature Closed

#45877Adding an UnlessViewHelper convenience

Pascal Dürsteler 02/27/13, 10:01 updated 01/06/15, 21:47

Description

AFAIK, you currently have to do something like this if you want to conditionally display something if it is not the case:

  <f:if condition="{...}">
    <f:then></f:then>
    <f:else>
      I just want this to be displayed and don't need the "if true case".
    </f:else>
  </f:if>

Peeking at ruby, I think some syntactic sugar could simplify this:

  <f:unless condition="{...}">
    <f:then>I like this</f:then>
  </f:unless>

This, of course, also accepts an else block. With this, however, you’ll have the same amount of markup, but it may integrate better into your view logic.

  <f:unless condition="{...}">
    <f:then>not the case</f:then>
    <f:else>the case</f:else>
  </f:if>

If this does not encounter much resistance, I’d like to submit a patch.

Reviews 1