Sha256: 524a5c0d909d5086bcfbe989aa04dde8c796d2f149c357df351f59169e42caf5
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
module Lookbook module PreviewControllerActions extend ActiveSupport::Concern included do helper PreviewHelper prepend_view_path Engine.root.join("app/views") before_action :permit_embeds def render_scenario_to_string(preview, scenario_name) prepend_application_view_paths prepend_preview_examples_view_path @preview = preview @scenario_name = scenario_name @render_args = @preview.render_args(@scenario_name, params: params.permit!) template = @render_args[:template] locals = @render_args[:locals] opts = {} opts[:layout] = nil opts[:locals] = locals if locals.present? with_optional_action_view_annotations do render html: render_to_string(template, **opts) end end def render_in_layout_to_string(template, locals, opts = {}) with_optional_action_view_annotations do html = render_to_string(template, locals: locals, **determine_layout(opts[:layout])) if opts[:append_html].present? html += opts[:append_html] end render html: html end end protected def with_optional_action_view_annotations(&block) disable = Lookbook.config.preview_disable_action_view_annotations ActionViewAnnotationsHandler.call(disable_annotations: disable, &block) end def permit_embeds headers["X-Frame-Options"] = Lookbook.config.preview_embeds.policy end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lookbook-2.0.0.beta.0 | lib/lookbook/preview_controller_actions.rb |