Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Array modifier order matters, but shouldn't #974

Closed
curtisblackwell opened this issue Sep 21, 2016 · 7 comments
Closed

Array modifier order matters, but shouldn't #974

curtisblackwell opened this issue Sep 21, 2016 · 7 comments

Comments

@curtisblackwell
Copy link

Expected behaviour

I should be able to place my modifiers in any order and get the same results.

Actual behaviour

Placing offset after limit returns unexpected results.

Steps to reproduce

  1. Have an array.
  2. Iterate over that array with a set limit and offset (with limit first).
@jackmcdade
Copy link
Member

Nope, Modifiers are 100% order dependent by design.

@curtisblackwell
Copy link
Author

😢 :trombone:

@jackmcdade
Copy link
Member

Think about it. Each modifier modifies the data and then sends it back. If you offset and then limit, or limit and then offset, you're going to have two totally different results.

@jasonvarga
Copy link
Member

{{ string | backspace:2 | reverse }}

Without order, what would you expect to happen here?

@curtisblackwell
Copy link
Author

I guess I just don't see why the order should matter for limit and offset. When would you ever want to limit then offset? Though it's definitely not worth breaking the mold over.

@jackmcdade
Copy link
Member

Those would be maybe the only two you'd want to work that way. And then we'd need to find a way to make them bypass the normal Modifier logic, and then document that those two are special... best to just order them as you will, and move on.

@curtisblackwell
Copy link
Author

Right, I agree. Just didn't think of them as modifiers since I wrote them like parameters.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants