mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Preserve literal semantics in strict2 case/when
Previously, strict2 case/when used `safe_parse_expression`
to parse when expressions causing `blank`/`empty` to be
treated as string literals (Expression::LITERALS maps 'empty' => ''),
rather than method literals
This caused unexpected behavior:
```
{%- case empty_obj -%}
{%- when empty -%}
previously: doesn't render (empty_obj == '' is false)
now: renders (empty_obj.empty? is true)
{%- endcase -%}
```
This commit instead calls `Condition.parse_expression`
with `safe: true`, which will correctly handle `blank`
and `empty`
This commit is contained in:
@@ -118,7 +118,7 @@ module Liquid
|
||||
parser = @parse_context.new_parser(markup)
|
||||
|
||||
loop do
|
||||
expr = safe_parse_expression(parser)
|
||||
expr = Condition.parse_expression(parse_context, parser.expression, safe: true)
|
||||
block = Condition.new(@left, '==', expr)
|
||||
block.attach(body)
|
||||
@blocks << block
|
||||
|
||||
Reference in New Issue
Block a user