Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added isodd operator #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added isodd operator #7

wants to merge 1 commit into from

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