-
-
Notifications
You must be signed in to change notification settings - Fork 475
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
Bad reverse filter output because Liquid is outdated #862
Comments
Same issue as #1334 ? |
Bumped into the same issue. Liquid reverses the collection in place! "Fixed" it by creating my own filter. config.addLiquidFilter("reverse", (collection) => {
const arr = [...collection];
return arr.reverse();
}); |
Duplicate of #469 The major upgrade will ship with 1.0 |
Hi, I am using Eleventy 1.0.0 and I am getting this error at build time:
The file in the error contains this: {% assign filinge = site.filinge | reverse %}
{% for post in filinge %}
<a href='{{ post.url }}'>{{ post.title }}</a>
{% endfor %} I tried using @Savjee’s solution by adding his script to my |
@xplosionmind Yeah, I'd imagine overriding the The error almost sounds like your
Is your repo public? If so I can take a look. // .eleventy.js snippet
eleventyConfig.addFilter("inspect", require("util").inspect); Then: <pre>{{ site.filinge | inspect }}</pre> UPDATE: FWIW, this worked for me in Eleventy v1.0.0: // src/_data/site.js
module.exports = {
filinge: [
{ title: "OnE", url: "/one" },
{ title: "TwO", url: "/two" },
{ title: "ThReE", url: "/three" },
],
}; ---
# src/pages/filinge.html
title: Filinge
---
<h1>{{ title }}</h1>
<!-- Where `site.filinge` is the `filinge` property in my src/_data/site.js file. -->
{% assign filinge = site.filinge | reverse %}
<!-- reverse sorted -->
{% for post in filinge %}
<a href='{{ post.url }}'>{{ post.title }}</a>
{% endfor %}
<!-- raw data -->
<pre>{{ site.filinge | inspect }}</pre> OUTPUT<h1>Filinge</h1>
<a href='/three'>ThReE</a>
<a href='/two'>TwO</a>
<a href='/one'>OnE</a>
<pre>[
{ title: 'OnE', url: '/one' },
{ title: 'TwO', url: '/two' },
{ title: 'ThReE', url: '/three' }
]</pre> |
Describe the bug
When I use the Liquid reverse filter (Not the reverse() function) to revet a collection it works bad if I use more than one time in the website for the same collection.
To Reproduce
This is my working example:
Outputs:
But if I use the same code also in other page:
Outputs:
Environment:
Additional context
In the issue #532 an user comment the same problem, but he said that is a problema that Liquid solved in the v8.3.2.
I think that the problem is that 11ty still use the v6.4.3.
The text was updated successfully, but these errors were encountered: