Skip to content

Slice with negative index doesn't match documented/Twig behavior

Hi,

We're big fans of the project - thank you for maintaining this!

Per this page in the docs: https://gitlab.com/nightlycommit/twing/-/blob/6.x/docs/language-reference/filters/slice.md (and expected behavior seen in Twig), negative lengths will exclude abs(length) elements from the end of the sequence. For example, {{ myvar | slice(10, -10) }} would exclude the first 10 and last 10 elements. This behavior doesn't appear to be implemented in this library (https://gitlab.com/nightlycommit/twing/-/blob/6.x/src/lib/extension/core/filters/slice.ts), and only the behavior for positive lengths is implemented.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information