Giter VIP home page Giter VIP logo

Comments (4)

Keats avatar Keats commented on May 18, 2024

Those are built-in Tera filters. I don't think it makes sense changing the behaviour because they work on the array, they have no concept of ordering. pages | first would return the earliest if sorting by date for example but pages | reverse | first would return the latest.

Changing the meaning of first and last filter would also affect any use of the filters on other arrays, which would be even more counterintuitive imo

from zola.

phil-opp avatar phil-opp commented on May 18, 2024

pages | first would return the earliest if sorting by date

Would it? I think the array is ordered newest-first, so it would return the latest.

Changing the meaning of first and last filter would also affect any use of the filters on other arrays, which would be even more counterintuitive imo

Maybe we could order the pages array ascending (by date/order). Then pages|first would return the earliest page and pages|last the latest. We could still iterate over it in newest-first order by using the reverse filter.

from zola.

Keats avatar Keats commented on May 18, 2024

Would it? I think the array is ordered newest-first, so it would return the latest.

Yes sorry.

Maybe we could order the pages array ascending (by date/order).

I'm not sure it makes sense tbh. first and last are going to be used way less than just iterating through the pages, and in that case you want descending.
I think the current behaviour is the one that makes the most sense overall

from zola.

phil-opp avatar phil-opp commented on May 18, 2024

first and last are going to be used way less than just iterating through the pages

Yeah, maybe you're right. It would be great if the set pages = pages | reverse syntax existed in Tera. Then everyone could just use the ordering they like.

from zola.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.