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 use Identifier as object index #209

Closed
chippers opened this issue Oct 10, 2018 · 7 comments · Fixed by cobalt-org/cobalt.rs#533
Closed

Cannot use Identifier as object index #209

chippers opened this issue Oct 10, 2018 · 7 comments · Fixed by cobalt-org/cobalt.rs#533
Labels
enhancement Improve the expected

Comments

@chippers
Copy link

liquid-rust version: 0.16.1 (cobalt 0.13.2)
rust version: 1.29.1
OS: Xubuntu 18.04

Hi again!

It's currently not possible to use an identifier as an object index. This is useful for when you have a post with an author slug in the frontmatter data, and have all author data in another data file. Below is a small test case (although a bit useless in this specific test)

{% for kv in site.data.authors %}
{% assign key = kv[0] %}
* {{ site.data.authors[key] }}: {{ site.data.authors[key].name }}
{% endfor %}

Cobalt v0.13.2 will spit out:

Error: build command failed
Caused by: Failed to render content for "index.html"
Caused by: liquid: Expected string | whole number, found `[`
from: {% for kv in site.data.authors  %}

Look like this comes from https://github.com/cobalt-org/liquid-rust/blob/master/liquid-compiler/src/parser.rs#L96 , but I don't know how the previous patch to allow multiple tokens for identifiers will work with it, as it also has token amounts hardcoded.

@epage
Copy link
Member

epage commented Oct 10, 2018

btw this is a dup of #145

@epage
Copy link
Member

epage commented Oct 10, 2018

Granted, it might be easier to implement a subset (just an identifier) of #145 (unsure how complex the expressions can get) so if thats all thats needed, I might be able to get this implemented without the new parser.

@chippers
Copy link
Author

ah i did not read the current issues carefully enough

Yeah, as far as I can see the current codebase only uses things like {% assign author = site.data.authors[page.data.source.author] %} so that should be good enough for now

@epage
Copy link
Member

epage commented Oct 11, 2018

As a heads up, I'm a little busier this week so it will take a little longer for me to turn around an implementation for this.

@epage epage added the enhancement Improve the expected label Oct 11, 2018
epage added a commit to epage/liquid-rust that referenced this issue Oct 18, 2018
@epage
Copy link
Member

epage commented Oct 18, 2018

Finally got #214 up, sorry for the delay.

@epage
Copy link
Member

epage commented Oct 18, 2018

liquid 0.17.0 is publishing right now. I'll have to get to updating cobalt tomorrow.

epage added a commit to epage/cobalt.rs that referenced this issue Oct 18, 2018
Breaking Changes

* **for_block:**  make ranges inclusive. ([42055c35](cobalt-org/liquid-rust@42055c3))

Features

* Indexing by variable ([c216a439](cobalt-org/liquid-rust@c216a43), closes [cobalt-org#209](cobalt-org/liquid-rust#209))
* **for_block:**  support parameters with variables ([7376ccf5](cobalt-org/liquid-rust@7376ccf), closes [cobalt-org#162](cobalt-org/liquid-rust#162))
* **filters:**
  * Added: "at_most" ([be3e55c0](cobalt-org/liquid-rust@be3e55c))
  * Added: "at_least" ([be3e55c0](cobalt-org/liquid-rust@be3e55c))
* **tags:**
  * Added tablerow ([18660736](cobalt-org/liquid-rust@1866073), closes [cobalt-org#163](cobalt-org/liquid-rust#163))
  * Added ifchanged ([18660736](cobalt-org/liquid-rust@1866073), closes [cobalt-org#163](cobalt-org/liquid-rust#163))
  * Added increment ([18660736](cobalt-org/liquid-rust@1866073), closes [cobalt-org#163](cobalt-org/liquid-rust#163))
  * Added decrement ([18660736](cobalt-org/liquid-rust@1866073), closes [cobalt-org#163](cobalt-org/liquid-rust#163))

Bug Fixes

* **for_block:**  make ranges inclusive. ([42055c35](cobalt-org/liquid-rust@42055c3))
@epage
Copy link
Member

epage commented Nov 19, 2018

@chippers I just wanted to check in since it has been a while since I've heard anything. How are cobalt / liquid treating you?

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