Fix spec adapter for liquid-spec API (template, assigns, options)

This commit is contained in:
Tobi Lutke
2026-01-01 21:59:16 -05:00
parent 53641e19ce
commit d321adae77
+8 -6
View File
@@ -18,17 +18,19 @@ LiquidSpec.compile do |source, options|
end end
# Render a compiled template with the given context # Render a compiled template with the given context
LiquidSpec.render do |template, ctx| # @param template [Liquid::Template] compiled template
static_registers = ctx.registers # @param assigns [Hash] environment variables
registers = Liquid::Registers.new(static_registers) # @param options [Hash] :registers, :strict_errors, :exception_renderer
LiquidSpec.render do |template, assigns, options|
registers = Liquid::Registers.new(options[:registers] || {})
context = Liquid::Context.build( context = Liquid::Context.build(
static_environments: ctx.environment, static_environments: assigns,
registers: registers, registers: registers,
rethrow_errors: ctx.rethrow_errors?, rethrow_errors: options[:strict_errors],
) )
context.exception_renderer = ctx.exception_renderer if ctx.exception_renderer context.exception_renderer = options[:exception_renderer] if options[:exception_renderer]
template.render(context) template.render(context)
end end