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

Variables don't render in time for usage in context. I.e. cannot be used as Array keys. #32

Open
jonnypaper opened this issue May 3, 2016 · 0 comments

Comments

@jonnypaper
Copy link

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 %}

@jonnypaper 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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant