handlebars-helpers icon indicating copy to clipboard operation
handlebars-helpers copied to clipboard

ifNth arguments seem to be switched

Open evenfrost opened this issue 8 years ago • 2 comments

https://github.com/helpers/handlebars-helpers/blob/5d3405f178a9ec4c90df3c7dc07b4faf9a09dfd7/lib/comparison.js#L328

Is there any idea behind switching arguments (b % a) here? Documentation says that

Conditionally renders a block if the remainder is zero when a operand is divided by b.

but logic seems to be inverse. I spent plenty of time trying to figure out why my ifNth is not working as supposed, or I just don't get it.

evenfrost avatar Jan 31 '18 09:01 evenfrost

The following test shows an example of the usage:

https://github.com/helpers/handlebars-helpers/blob/20a2fa1bcbf7817a7814904247319972c2fcd44b/test/comparison.js#L381-L401

I agree that the documentation could be updated to show an example and clear up which is argument is dividing the other. Would you like to do a PR to update the code comments? I think the logic is correct because the usage in the test "feels" more natural to me.

doowb avatar Jan 31 '18 16:01 doowb

Sure, landed here: https://github.com/helpers/handlebars-helpers/pull/307.

evenfrost avatar Feb 01 '18 10:02 evenfrost