You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When rendering templates the variables are not being rendered in time for use in context.
Example:
<ul class="nav">
{% for link in navigation.main-navigation.links %}
<li class="cf">
<a href="{{ link.url }}">{{ link.link_name }}</a>
<ul class="nav">
{% for l in navigation[link.handle].links %}
<li><a href="{{ l.url }}"{% if l.active %} class="current"{% endif %}>{{ l.link_name }}</a></li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
The key issue in the above:
When attempting to utilise for loop variables as array keys they fail.
The desired affect (and how Shopify liquid works), is the variable is output as it's value, before further liquid markup is rendered, meaning the variable value can then be used right away in context. In this case, as an array key. The correct output example: {% for l in navigation[my-link-handle-value-after-being-rendered].links %}
Instead it's not rendered and you're left with the variable name itself. Current output example: {% for l in navigation[link.handle].links %}
The text was updated successfully, but these errors were encountered:
jonnypaper
changed the title
Variables don't render before For loops.
Variables don't render in time for usage in context.
May 3, 2016
jonnypaper
changed the title
Variables don't render in time for usage in context.
Variables don't render in time for usage in context. I.e. cannot be used as Array keys.
May 3, 2016
When rendering templates the variables are not being rendered in time for use in context.
Example:
The key issue in the above:
When attempting to utilise for loop variables as array keys they fail.
The desired affect (and how Shopify liquid works), is the variable is output as it's value, before further liquid markup is rendered, meaning the variable value can then be used right away in context. In this case, as an array key.
The correct output example:
{% for l in navigation[
my-link-handle-value-after-being-rendered
].links %}Instead it's not rendered and you're left with the variable name itself.
Current output example:
{% for l in navigation[
link.handle
].links %}The text was updated successfully, but these errors were encountered: