Module: Lookbook::PreviewActions
- Defined in:
- lib/lookbook/preview_actions.rb
Class Method Summary collapse
Instance Method Summary collapse
- #render_example_to_string(preview, example_name) ⇒ Object
- #render_in_layout_to_string(template, locals, opts = {}) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
3 4 5 |
# File 'lib/lookbook/preview_actions.rb', line 3 def self.included(klass) klass.helper Lookbook::PreviewHelper end |
Instance Method Details
#render_example_to_string(preview, example_name) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lookbook/preview_actions.rb', line 7 def render_example_to_string(preview, example_name) prepend_application_view_paths prepend_preview_examples_view_path @preview = preview @example_name = example_name @render_args = @preview.render_args(@example_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 |
#render_in_layout_to_string(template, locals, opts = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lookbook/preview_actions.rb', line 24 def render_in_layout_to_string(template, locals, opts = {}) append_view_path Lookbook::Engine.root.join("app/views") 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 |