mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-04 01:25:14 -07:00
Fix spec adapter for liquid-spec API (template, assigns, options)
This commit is contained in:
+8
-6
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user