Update liquid-spec adapters for new ctx-based API

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]>
This commit is contained in:
Charles-P. Clermont
2026-01-13 13:06:55 -05:00
co-authored by Claude Opus 4.5
parent 7d90b524ea
commit aa817c4cfd
5 changed files with 18 additions and 21 deletions
+5 -6
View File
@@ -13,16 +13,15 @@ LiquidSpec.configure do |config|
end
# Compile a template string into a Liquid::Template
LiquidSpec.compile do |_ctx, source, options|
Liquid::Template.parse(source, **options)
LiquidSpec.compile do |ctx, source, options|
ctx[:template] = Liquid::Template.parse(source, **options)
end
# Render a compiled template with the given context
# @param ctx [Hash] adapter context (unused)
# @param template [Liquid::Template] compiled template
# @param ctx [Hash] adapter context containing :template
# @param assigns [Hash] environment variables
# @param options [Hash] :registers, :strict_errors, :exception_renderer
LiquidSpec.render do |_ctx, template, assigns, options|
LiquidSpec.render do |ctx, assigns, options|
registers = Liquid::Registers.new(options[:registers] || {})
context = Liquid::Context.build(
@@ -33,5 +32,5 @@ LiquidSpec.render do |_ctx, template, assigns, options|
context.exception_renderer = options[:exception_renderer] if options[:exception_renderer]
template.render(context)
ctx[:template].render(context)
end
+4 -4
View File
@@ -12,14 +12,14 @@ LiquidSpec.configure do |config|
end
# Compile a template string into a Liquid::Template
LiquidSpec.compile do |_ctx, source, options|
LiquidSpec.compile do |ctx, source, options|
# Force lax mode
options = options.merge(error_mode: :lax)
Liquid::Template.parse(source, **options)
ctx[:template] = Liquid::Template.parse(source, **options)
end
# Render a compiled template with the given context
LiquidSpec.render do |_ctx, template, assigns, options|
LiquidSpec.render do |ctx, assigns, options|
registers = Liquid::Registers.new(options[:registers] || {})
context = Liquid::Context.build(
@@ -30,5 +30,5 @@ LiquidSpec.render do |_ctx, template, assigns, options|
context.exception_renderer = options[:exception_renderer] if options[:exception_renderer]
template.render(context)
ctx[:template].render(context)
end
+5 -6
View File
@@ -14,16 +14,15 @@ LiquidSpec.configure do |config|
end
# Compile a template string into a Liquid::Template
LiquidSpec.compile do |_ctx, source, options|
Liquid::Template.parse(source, **options)
LiquidSpec.compile do |ctx, source, options|
ctx[:template] = Liquid::Template.parse(source, **options)
end
# Render a compiled template with the given context
# @param ctx [Hash] adapter context (unused)
# @param template [Liquid::Template] compiled template
# @param ctx [Hash] adapter context containing :template
# @param assigns [Hash] environment variables
# @param options [Hash] :registers, :strict_errors, :exception_renderer
LiquidSpec.render do |_ctx, template, assigns, options|
LiquidSpec.render do |ctx, assigns, options|
registers = Liquid::Registers.new(options[:registers] || {})
context = Liquid::Context.build(
@@ -34,5 +33,5 @@ LiquidSpec.render do |_ctx, template, assigns, options|
context.exception_renderer = options[:exception_renderer] if options[:exception_renderer]
template.render(context)
ctx[:template].render(context)
end
+4 -4
View File
@@ -19,14 +19,14 @@ LiquidSpec.configure do |config|
end
# Compile a template string into a Liquid::Template
LiquidSpec.compile do |_ctx, source, options|
LiquidSpec.compile do |ctx, source, options|
# Force strict mode
options = { error_mode: :strict }.merge(options)
Liquid::Template.parse(source, **options)
ctx[:template] = Liquid::Template.parse(source, **options)
end
# Render a compiled template with the given context
LiquidSpec.render do |_ctx, template, assigns, options|
LiquidSpec.render do |ctx, assigns, options|
registers = Liquid::Registers.new(options[:registers] || {})
context = Liquid::Context.build(
@@ -37,5 +37,5 @@ LiquidSpec.render do |_ctx, template, assigns, options|
context.exception_renderer = options[:exception_renderer] if options[:exception_renderer]
template.render(context)
ctx[:template].render(context)
end