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 inside unless do not work as expected #160

Closed
wturnerharris opened this issue Oct 1, 2019 · 1 comment
Closed

Variables inside unless do not work as expected #160

wturnerharris opened this issue Oct 1, 2019 · 1 comment

Comments

@wturnerharris
Copy link

@harttle - hello!

We've encountered an issue with the unless tag where variables within the unless tag are not rendered. We have tried both an captured and assigned tag variables and one provided directly in the context.

Please see the test case below:

var { Liquid } = require('liquidjs');
var engine = new Liquid();

engine.parseAndRender(`
{%- capture quantity -%}
  <input type="number" step="1" />
{%- endcapture -%}

{%- assign test_var = 'logo.png' -%}

<div>
  <p>This is outside of unless:</p>
  Location: {{ location }}
  Quantity: {{ quantity }}
  Test Var: {{ test_var }}
</div>
{% unless location == 'alice' %}
<div class="not-alice">
  <p>This is inside the unless</p>
  <ul>
    <li>Location: {{ location }}</li>
    <li>Quantity: {{ quantity }}</li>
    <li>Test Var: {{ test_var }}</li>
  </ul>
</div>
{% endunless %}
<div>
  <p>This is after the unless</p>
  Location: {{ location }}
  Quantity: {{ quantity }}
  Test Var: {{ test_var }}
</div>
`, {location: 'wonderland'}).then(console.log);

Output with location=wonderland:

<div>
  <p>This is outside of unless:</p>
  Location: wonderland
  Quantity: <input type="number" step="1" />
  Test Var: logo.png
</div>

<div class="not-alice">
  <p>This is inside the unless</p>
  <ul>
    <li>Location: 
<div>
  <p>This is after the unless</p>
  Location: wonderland</li>
    <li>Quantity: wonderland
  Quantity: <input type="number" step="1" /></li>
    <li>Test Var: <input type="number" step="1" />
  Test Var: logo.png</li>
  </ul>
</div>
logo.png
</div>

Output with location=alice:

<div>
  <p>This is outside of unless:</p>
  Location: alice
  Quantity: <input type="number" step="1" />
  Test Var: logo.png
</div>

<div>
  <p>This is after the unless</p>
  Location: alice
  Quantity: <input type="number" step="1" />
  Test Var: logo.png
</div>

We expect that:

  • The unless condition would behave like the outside conditions, which you can experience by changing the context variable location to alice
  • All three test variables that render inside the unless tag would be consistent with the ones outside.
  • The variables would be in the proper order, which you will see that they are not in the test case output.
@harttle harttle added the bug label Oct 2, 2019
@harttle harttle closed this as completed in d2c8d13 Oct 2, 2019
harttle pushed a commit that referenced this issue Oct 2, 2019
## [9.0.1](v9.0.0...v9.0.1) (2019-10-02)

### Bug Fixes

* `unless` content is not waited, fixes [#160](#160) ([d2c8d13](d2c8d13))
@harttle
Copy link
Owner

harttle commented Oct 2, 2019

🎉 This issue has been resolved in version 9.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants