Commit Graph
1128 Commits
Author SHA1 Message Date
Charles-P. ClermontandClaude Opus 4.5 26cb29487b fix(parser): implement RTL associativity for boolean expressions
- Use right-recursive descent for proper RTL precedence
- Add bin/liquid-spec-all-adapters for CI workflow
- Update CI to use dedicated script

Fixes 128 precedence test failures from original implementation.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
2026-01-28 09:09:19 -05:00
Charles-P. Clermont ef4770975b Fix MethodLiteral for updated blank & empty 2026-01-27 10:07:36 -05:00
Charles-P. Clermont a4e82eb5c1 Annotate Parser with grammar rules 2026-01-27 10:07:35 -05:00
Charles-P. Clermont 10c0de74b5 Add support for parenthesized expressions 2026-01-27 10:07:35 -05:00
Charles-P. Clermont f9b5313020 Prepare logical for grouping 2026-01-27 10:07:35 -05:00
Charles-P. Clermont 7f414e5fa6 Remove Condition#{child_relation,and,or}
- Remove Condition#child_relation
- Remove Condition#and
- Remove Condition#or
- Simplify Condition#evaluate

This logic was moved to the Parser & BinaryExpression
2026-01-27 10:07:35 -05:00
Charles-P. Clermont 429711fd82 Add support for logical expressions 2026-01-26 16:53:38 -05:00
Charles-P. Clermont e911eea3df Remove Condition.op, Condition.right
- Remove comparison expression logic
2026-01-26 16:52:46 -05:00
Charles-P. Clermont daae2186d2 Make Condition unit tests go through BinaryExpression
Instead of having Condition parse the left op right, make
BinaryExpression do it. Make sure all the tests pass as they
used to in the process.
2026-01-26 16:52:31 -05:00
Charles-P. Clermont f60d3f0a41 Use BinaryExpression instead of Condition for comparisons 2026-01-26 16:52:31 -05:00
Charles-P. Clermont 0b890904f0 Make Parser.expression parse equality expressions 2026-01-26 16:52:31 -05:00
Charles-P. Clermont b161dae495 Make Parser.expression parse comparisons 2026-01-26 16:52:31 -05:00
Charles-P. ClermontandClaude Opus 4.5 6f03452245 style: fix rubocop offenses
Co-Authored-By: Claude Opus 4.5 <[email protected]>
2026-01-26 16:52:21 -05:00
Charles-P. ClermontandClaude Opus 4.5 1b420ab6d8 fix(case): use Condition.parse_expression for empty/blank handling
Co-Authored-By: Claude Opus 4.5 <[email protected]>
2026-01-26 16:52:21 -05:00
Charles-P. Clermont 18f1e8a61e Replace Context[]'s Expression.parse with Parser#expression 2026-01-26 16:52:17 -05:00
Charles-P. Clermont dff829ec72 Extract Parser#range_lookup out of Expression.parse 2026-01-26 16:52:17 -05:00
Charles-P. Clermont 8b04c52ab2 Extract Parser#variable_lookup out of Expression.parse 2026-01-26 16:52:17 -05:00
Charles-P. Clermont 8efcf7dd3a Move VariableLookup parsing logic to .parse instead of initializer
Goal is to get rid of it entirely, but baby steps.
2026-01-26 16:52:17 -05:00
Charles-P. Clermont af774ebc55 Replace RangeLookup.parse with RangeLookup.create 2026-01-26 16:52:17 -05:00
Charles-P. Clermont 288c4eaac3 Simplify parse_number
We don't need all the multi-dot logic in a world where number comes
out of the Lexer.
2026-01-26 16:52:17 -05:00
Charles-P. Clermont e1e0129983 Extract Parser#number parse out of Expression.parse 2026-01-26 16:52:17 -05:00
Charles-P. Clermont 2a86852eb3 Extract Parser#string out of Expression.parse 2026-01-26 16:52:17 -05:00
Charles-P. Clermont 85d73e462d Remove Expression#safe_parse 2026-01-26 16:52:17 -05:00
Charles-P. Clermont c9ae128354 Rename Parser#expression_node -> Parser#expression 2026-01-26 16:52:17 -05:00
Charles-P. Clermont 6cfcd6cac0 Rename Parser#argument -> argument_string 2026-01-26 16:52:17 -05:00
Charles-P. Clermont 6b78291449 Rename Parser#expression -> Parser#expression_string 2026-01-26 16:52:17 -05:00
Charles-P. Clermont 7d0bdd166d Move parse_expression to Parser.unsafe_parse_expression
- Add Parser#string
- Add Parser#unsafe_parse_expression
- Add private Parser#parse_expression
- Remove ParseContext.parse_expression
- Remove Tag.parse_expression
- Condition.parse_expression now takes a parser as argument
2026-01-26 16:52:17 -05:00
Charles-P. Clermont cf3d845315 Move safe_parse_expression into Parser.expression_node
- Make `Parser` accept the expression cache
- Remove `safe_parse_expression` from `ParseContext`
- Replace all usage of `safe_parse_expression` with `parser.expression_node`
2026-01-26 16:52:17 -05:00
Charles-P. Clermont f4a5454cd6 Remove warnings system 2026-01-14 09:55:21 -05:00
Charles-P. Clermont 62400f71d0 Remove :error_mode 2026-01-14 09:55:20 -05:00
Charles-P. Clermont b7fa6a89b3 Rename strict2_parse to parse_markup 2026-01-14 09:54:19 -05:00
Charles-P. Clermont d936ce4ac9 Remove :lax, :strict and :warn error modes 2026-01-14 09:54:19 -05:00
Tobi LutkeandClaude Opus 4.5 ccd05e869c Make blank/empty comparisons invariant to ActiveSupport
- Implement liquid_blank? and liquid_empty? methods in Condition
  to emulate ActiveSupport's behavior when it's not loaded
- This ensures templates like `{% if x == blank %}` work identically
  whether ActiveSupport is loaded or not
- Update liquid-spec adapters for new API (ctx parameter)
- Add rake spec task for running liquid-spec matrix

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
2026-01-05 14:54:43 -10:00
Tobi Lutke ef13b2dfd5 Fix empty? semantics and string first/last for empty strings
- nil is NOT empty (but IS blank) - matches Shopify production
- String first/last returns '' for empty strings, not nil - matches ActiveSupport
- Add test for nil not being empty
2026-01-01 22:06:22 -05:00
Tobi Lutke af58800c16 Update rubocop-shopify to 2.18.0 and fix new offenses 2026-01-01 20:22:19 -05:00
Tobi Lutke 361d1d52b1 Fix rubocop offenses from 1.82 upgrade 2026-01-01 20:20:50 -05:00
Tobi Lutke 0e3548d39e Remove redundant else-clause 2026-01-01 20:16:24 -05:00
Tobi Lutke 33bac87a5c Address liquid-spec issues without ActiveSupport loaded
Implement ActiveSupport-compatible behaviors internally so Liquid works
correctly without ActiveSupport being loaded:

1. String first/last via property access (name.first, name.last)
   - VariableLookup now handles string[0] and string[-1] for first/last

2. String first/last via filters (name | first, name | last)
   - StandardFilters#first and #last now handle strings

3. blank?/empty? comparisons for types without these methods
   - Condition now implements liquid_blank? and liquid_empty? internally
   - blank? matches ActiveSupport: nil, false, empty/whitespace strings,
     empty arrays/hashes are all blank
   - empty? checks length == 0 only (whitespace is NOT empty)

This fixes spec failures for templates like:
- {{ name.first }} / {{ name | first }} on strings
- {% if x == blank %} for whitespace strings, empty hashes/arrays
- {% case ' ' %}{% when blank %} matching whitespace
2026-01-01 20:14:21 -05:00
Ian Ker-SeymerandGitHub 22e979a6fa Use floating-point format for BigDecimal stringification (#2022)
## Summary

- BigDecimal values now stringify using `to_s("F")` format instead of the default `to_s`

## Why

Ruby's default `BigDecimal#to_s` produces engineering/scientific notation for certain values:

```ruby
BigDecimal("0.00001").to_s      # => "0.1E-4"
BigDecimal("12345678.9").to_s   # => "0.123456789E8"
```

This is rarely the desired output in templates. Using `to_s("F")` produces the expected floating-point format:

```ruby
BigDecimal("0.00001").to_s("F")      # => "0.00001"
BigDecimal("12345678.9").to_s("F")   # => "12345678.9"
```
2025-12-05 15:54:52 -05:00
Julia Boutin fa27bfe6e0 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`
2025-11-28 15:51:48 -07:00
Guilherme CarreiroandGitHub 32b50ecafe Bump Liquid to 5.11.0 (#2012)
This commit reverts the Inline Snippets tag (#2001) and bumps
Liquid to 5.11. For now, the inclusion of Inline Snippets
in the latest Liquid release is being treated as a bug.

While #2001 does implement the scope contained in RFC#1916,
we need to take a step back to make sure we’re setting our
sights high enough with this feature, and that we’re truly
supporting theme developers in the ways they need.

If you have any feedback, please leave a comment on RFC#1916.

- Liquid Developer Tools
2025-11-19 18:03:23 +01:00
Gray Gilmore 9973f3399e Don't raise if no variable found when using context.key?
Previously if you set `strict_variables` to `true` on the context using
`key?('key_name')` would raise a `Liquid::UndefinedVariable` error.
Raising this error makes sense if you're trying to access the variable
directly with something like  `context['key_name']` but by using `key?`
you're safely checking if it exists first.

You should be able to enable `strict_variables` and use `key?` in
combination with each other to ensure code safety.
2025-10-30 15:33:07 -07:00
Guilherme CarreiroandGuilherme Carreiro 248f3a412f Bump to 5.10.0 2025-10-30 12:28:52 +01:00
Guilherme CarreiroandGuilherme Carreiro a16ec56a40 Update error handling for keeping backward-compatibility on error messages in the render tag 2025-10-30 12:00:44 +01:00
Julia BoutinandGuilherme Carreiro 12fd93fbe2 Missing inline snippets should display same error as filebased 2025-10-30 12:00:44 +01:00
Julia BoutinandGuilherme Carreiro 5ceb0e9cec Raise error on invalid snippet name 2025-10-30 12:00:44 +01:00
Julia BoutinandGuilherme Carreiro 98fbd985d8 Remove unneeded read method 2025-10-30 12:00:44 +01:00
Julia BoutinandGuilherme Carreiro ae05ba071c Add liquid_public_docs yard tag to snippet tag 2025-10-30 12:00:44 +01:00
Julia BoutinandGuilherme Carreiro 4205131148 Extract snippet resource scoring logic into assign_score_of 2025-10-30 12:00:44 +01:00
Julia BoutinandGuilherme Carreiro db350c54ff Allow render tag to recognize drops that respond to to_partial 2025-10-30 12:00:44 +01:00