Skip to content
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

Cannot iterate over "object" #201

Closed
chippers opened this issue Oct 3, 2018 · 4 comments · Fixed by #203
Closed

Cannot iterate over "object" #201

chippers opened this issue Oct 3, 2018 · 4 comments · Fixed by #203
Labels
enhancement Improve the expected

Comments

@chippers
Copy link

chippers commented Oct 3, 2018

liquid-rust version: 0.14.3 and 0.15.0 (cobalt v0.12.2 and master)
rust version: rustc 1.29.1 (b801ae664 2018-09-20)
OS: Xubuntu 18.04

Attempting to iterate over an object from data is not possible. A small reproduction with cobalt is available here with the cobalt build output:

chip@dev:~/temp/cobalt_liquid_iterate_for$ cobalt build
[info] Building from "/home/chip/temp/cobalt_liquid_iterate_for/" into "/home/chip/temp/cobalt_liquid_iterate_for/_site"
Error: build command failed
Caused by: Failed to render content for "index.html"
Caused by: liquid: Expected array, found `object`
from: {% for kv in site.data.authors  %}

I'm posting it here instead of the cobalt.rs repo since it seems this library is the root cause of the error. I tried with the latest release v0.12.2 (liquid-rust 0.14.3) and compiled from source from the master branch (liquid-rust 0.15.0).

I encountered this while porting the arewewebyet site from Jekyll to Cobalt, where the authors data file is iterated over once to get a list of curators, and then used elsewhere other times by other templates mostly as an object.

It definitely works in Jekyll, and the Liquid docs mention the types allowed in for loops. Here I'm assuming a hash is equivalent to what is called an object here, as it works as expected with Jekyll.

@epage epage added the enhancement Improve the expected label Oct 3, 2018
@epage
Copy link
Member

epage commented Oct 3, 2018

Thanks for reporting this!

I'll try to get to this tonight to unblock you.

btw that liquid document is a lot better than the one I've been using. I'll need to audit liquid-rust against that.

@chippers
Copy link
Author

chippers commented Oct 3, 2018

@epage
Copy link
Member

epage commented Oct 3, 2018

Thats what I get for using google rather than our own readme :)

@epage epage mentioned this issue Oct 4, 2018
16 tasks
epage added a commit to epage/liquid-rust that referenced this issue Oct 4, 2018
Not the fastest implementation but it will do for now.

Fixes cobalt-org#201
epage added a commit to epage/liquid-rust that referenced this issue Oct 4, 2018
Not the fastest implementation but it will do for now.

Fixes cobalt-org#201
@epage epage closed this as completed in #203 Oct 4, 2018
@epage
Copy link
Member

epage commented Oct 4, 2018

Cobalt PR: cobalt-org/cobalt.rs#526

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants