Skip to content

Commit

Permalink
fix: Fix liquid conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Jun 5, 2024
1 parent 5a0e8aa commit 39d6be1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/transform/liquid/conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function inlineConditions(

return {
result: start + result + end,
lastIndex: start.length + result.length,
lastIndex: start.length + result.length - tailLinebreak(ifTag.rawEnd).length,
ifCon,
};
}
Expand Down
36 changes: 36 additions & 0 deletions test/liquid/conditions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,42 @@ describe('Conditions', () => {
{% endnote %}
`);
});

test('Falsy block condition after truthly block condition', () => {
expect(
conditions(
trim`
Start
Before
{% if product == "A" %}
Truthly
{% endif %}
{% if product == "B" %}
Falsy
{% endif %}
After
End
`,
{
product: 'A',
},
'',
{
sourceMap: {},
},
),
).toEqual(trim`
Start
Before
Truthly
After
End
`);
});
});

describe('Conditions', () => {
Expand Down

0 comments on commit 39d6be1

Please sign in to comment.