Skip to content

Conversation

@mkay
Copy link

@mkay mkay commented Feb 22, 2012

Added an operator that checks if subject is odd or even.
Passes if the subject is an odd integer.

I needed this for generating empty table cells in getResources' &tplLast:

<td>[[+content]]</td>
[[!If? &subject=`[[+total]]` &operator=`isodd` &then=`<td>&nbsp;</td>`]]

hope it's useful.
Mika

Added an operator that checks if subject is odd or even.
Passes if the subject is an odd integer.
@jpdevries
Copy link

Given that If has historically included counter arguments (like isempty,empty), I think for something like this to be added it should also come with:

  • iseven
  • isnumber
  • !number

@algorski
Copy link

IMHO, this operator is excessive, because the call of

[[!If? &subject=[[+total]] &operator=isodd &then=<td>&nbsp;</td>]]

may be represented as

[[!If? &subject=[[+total:mod]] &operator=notempty &then=<td>&nbsp;</td>]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants