Shopify / liquid

Liquid markup language. Safe, customer facing template language for flexible web apps.

Home Page:https://shopify.github.io/liquid/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not support nested objects syntax.

liudonghua123 opened this issue · comments

Hi, I am new to liquid template language. What I want to achieve is like the following code.

<img src={{ '/assets/images/{{entry.logo}}' | relative_url }} class="fas">

But jekyll build failed with some errors like Liquid Exception: Liquid syntax error (/app/src/_includes/docs/app-figure.md line 22): Unexpected character ' in "{{ '/assets/images/docs/{{path}}". Should I rewrite the code using belows? Is there any simple solution for no assign a new variable?

{% assign entry_logo = '/assets/images/{{entry.logo}}' -%}
<img src={{ entry_logo | relative_url }} class="fas">

I tested on https://geekplayers.com/run-liquild-online.html and using append filter maybe work.

<img src={{ '/assets/images/' | append entry.logo | relative_url }} class="fas">

But how about some complicate expression like '/assets/images/{{dir}}/{{filename}}.{{extension}}'.

'/assets/images/' | append dir | append filename | append '.' | append extension ? It's too ugly.

Not work either. 😢

Liquid Exception: Liquid syntax error (/app/src/_includes/docs/app-figure.md line 22): Expected end_of_string but found id in "{{ '/assets/images/docs/' | append path | append include.image | relative_url }}" in accessibility-and-localization/accessibility.md.

In JavaScript, I can use nested template string naturally like this.

a1=123
b=1
`a${b}=${`a${b}`}`
`a${b}=${eval(`a${b}`)}`

Any ideas on how can I write some template code like <img src={{ '/assets/images/{{entry.logo}}' | relative_url }} class="fas">.

Not work either. 😢

Liquid Exception: Liquid syntax error (/app/src/_includes/docs/app-figure.md line 22): Expected end_of_string but found id in "{{ '/assets/images/docs/' | append path | append include.image | relative_url }}" in accessibility-and-localization/accessibility.md.

Sorry for filter syntax mistake, I forget : after filter name. This method works for me.