Skip to content

Commit 3a51fff

Browse files
committed
adjusted rendering to take rails layout by default until 'layout false' is set on controller level
1 parent 81466fd commit 3a51fff

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

lib/matestack/ui/core/helper.rb

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,27 @@ def render(*args)
2222
setup_context
2323
if args.first.is_a?(Class) && args.first.ancestors.include?(Base)
2424
raise 'expected a hash as second argument' unless args.second.is_a?(Hash) || args.second.nil?
25+
26+
begin
27+
controller_layout = self.class.send(:_layout)
28+
rescue
29+
controller_layout = nil
30+
end
31+
2532
options = args.second || {}
2633
app = options.delete(:matestack_app) || self.class.matestack_app
27-
layout = app ? app.layout : false
2834
page = args.first
35+
36+
if controller_layout == false
37+
layout = app ? app.layout : false
38+
else
39+
if controller_layout.nil?
40+
layout = "application"
41+
else
42+
layout = controller_layout
43+
end
44+
end
45+
2946
if app && params[:only_page].nil? && params[:component_key].nil? && params[:component_class].nil?
3047
render_app app, page, options, layout
3148
else
@@ -38,7 +55,11 @@ def render(*args)
3855
render html: params[:component_class].constantize.(public_options: JSON.parse(params[:public_options] || '{}'))
3956
end
4057
else
41-
render_page page, options, layout
58+
if params[:only_page]
59+
render_page page, options, false
60+
else
61+
render_page page, options, layout
62+
end
4263
end
4364
end
4465
else
@@ -51,7 +72,7 @@ def render_app(app, page, options, layout)
5172
end
5273

5374
def render_page(page, options, layout)
54-
render html: page.new(options).render_content.html_safe, layout: false
75+
render html: page.new(options).render_content.html_safe, layout: layout
5576
end
5677

5778
def render_component(app, page, component_key, options)

0 commit comments

Comments
 (0)