Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 93032

Accessing key/value pairs inside For loops

$
0
0

According to Shopify's docs, Liquid allows accessing key/value pairs in for loops, like so:

{% for item in hash %}   {{ item[0] }}: {{ item[1] }} {% endfor %}

 

This does not currently work in BC's Liquid renderer; the output of the key/value tags are blank. Here is an example using the always-available this.urlculture global object:

{   ...   "urlculture": {     "moduleName": "urlculture",     "culture": "EN"   },   ... }

 

{% for obj in this.urlculture %}    
{{ obj | json }}
    Key: {{ obj[0] }}
    Value: {{ obj[1] }}
{% endfor %}

 

Here's the output I get:

{  "Key": "moduleName",  "Value": "urlculture"
}

Key:
Value:

{
  "Key": "culture",  "Value": "EN"
}

Key:
Value: 

Accessing them by name (like {{ obj.Key }} ) also fails.

 

Am I missing something, or is this just not implemented yet?

 

Also, Why isn't the nice code formatting shown in this post editor visible in the actual post?


Viewing all articles
Browse latest Browse all 93032

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>