Both tags previously accepted any string as a variable name via
`markup.strip`. Now they use `parse_with_selected_parser` and validate
the variable name with `p.consume(:id)` in strict2 mode.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Both tags previously used only regex (VariableSignature) to validate
variable names, which allowed invalid identifiers like (a(b(c) and
[x.y] in all parse modes.
- assign: strict2_parse uses Parser to validate the LHS as a valid
identifier before delegating RHS to Variable
- capture: strict2_parse uses Parser to validate the variable name
as a valid identifier
- Both tags now include ParserSwitching and dispatch through
strict_parse_with_error_mode_fallback
- Lax mode is unchanged — invalid names are still accepted
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Store @is_for_loop during parsing so consumers can determine the
with/for keyword from the AST instead of re-parsing raw markup.
Matches the existing pattern in the Render tag.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add bare-bracket rejection to Parser#expression in strict2 mode, so that
`['var']` is disallowed and `self['var']` is the required syntax.
- Add `Expression::SELF` constant ('self')
- Add `Parser#reject_bare_brackets` option, checked in `expression`
- Add `ParseContext#reject_bare_brackets?` and `force_reject_bare_brackets`
- Add `VariableLookupDrop` for `self['var']` scope-chain lookups
- Add `Variable#==` for rewriter state comparison
- Update `Context#find_variable` to return `VariableLookupDrop` for `self`
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The pinned version (v1.273.0) does not have prebuilt `ruby-head` binaries
for `ubuntu-24.04`, which `ubuntu-latest` now resolves to. This causes CI
to fail with "Unavailable version head for ruby on ubuntu-24.04".
Updating to v1.295.0 picks up ubuntu-24.04 support for all Ruby versions
including head builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* feat: add cumulative resource score tracking across partial renders
Add cumulative_render_score and cumulative_assign_score counters to
ResourceLimits that accumulate across reset() calls, with optional
cumulative_render_score_limit and cumulative_assign_score_limit to
cap total work across all partial renders.
Also add a reached? check in BlockBody's render loop so that once a
cumulative limit triggers, the parent template stops processing
further nodes.
Bump version to 5.12.0.
* refactor: move cumulative limit enforcement into reset()
Instead of checking reached? in BlockBody's render loop, enforce
cumulative limits in reset() itself. Since reset() is called before
the begin/rescue MemoryError block in Template#render, the raise
propagates to the parent naturally — no changes to BlockBody needed.
liquid-spec main changed the adapter API:
- compile block now receives (ctx, source, options) and should store
the template in ctx[:template]
- render block now receives (ctx, assigns, options) and retrieves
the template from ctx[:template]
Co-Authored-By: Claude Opus 4.5 <[email protected]>
- 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]>
- 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
- Add liquid-spec gem from GitHub to :spec group
- Create spec/ruby-liquid.rb adapter for the reference implementation
- Add spec job to CI workflow to run liquid-spec tests
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
## 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"
```
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`