-
Notifications
You must be signed in to change notification settings - Fork 168
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
limit tag in for loops #504
Comments
Slice should help https://pebbletemplates.io/wiki/filter/slice/ |
Slice works great if you already know the length of an array you are about to slice. But if you enter a number bigger than the array length in
in contrast with My use case is to display the 4 most recent posts in my orchid website and my solution works but I was just wondering if there's something more idiomatic. |
I think that we can change slice and take the collection size when the toIndex is greater than the collection size. That way, you can achieve what you want. What do you think ? |
Yes that would work great for my case I think. Should you prefer to modify the slice operator instead of creating a new one, that I leave it up to you :) |
Fix's gonna be available in next release |
Hi,
is there a
limit
tag like there is in Liquid templating that would allow me to exit a loop at specified index?What I want:
How I worked this around
But my solution is too verbose and I don't like it. Any suggestions? Furthermore I'd enjoy having more tags like this for example
offset
maybebreak
orcontinue
as well as ranges.Am I asking for too much for a template language?
The text was updated successfully, but these errors were encountered: