From 950f3f6b1334833527e3e3cb2b397c58d279dede Mon Sep 17 00:00:00 2001 From: Mark Perkins Date: Wed, 22 Nov 2023 21:44:18 +0000 Subject: [PATCH] Ensure `assigns` are handled correctly when rendering previews --- lib/lookbook/preview.rb | 1 + lib/lookbook/preview_controller_actions.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/lookbook/preview.rb b/lib/lookbook/preview.rb index 6f165ee1d..2b0d3d04a 100644 --- a/lib/lookbook/preview.rb +++ b/lib/lookbook/preview.rb @@ -11,6 +11,7 @@ def render(component = nil, **args, &block) template: args[:template] || Lookbook.config.preview_template, args: args, locals: args[:locals] || {}, + assigns: args[:assigns] || {}, block: block } else diff --git a/lib/lookbook/preview_controller_actions.rb b/lib/lookbook/preview_controller_actions.rb index 7633ec588..002deaa4f 100644 --- a/lib/lookbook/preview_controller_actions.rb +++ b/lib/lookbook/preview_controller_actions.rb @@ -18,6 +18,7 @@ def render_scenario_to_string(preview, scenario) locals = @render_args[:locals] opts = {} opts[:layout] = nil + opts[:assigns] = @render_args[:assigns] || {} opts[:locals] = locals if locals.present? rendered = render_to_string(template, **opts)