@@ -2,22 +2,22 @@ module Matestack
22 module Ui
33 module Core
44 module Helper
5-
5+
66 def self . included ( base )
77 base . extend ClassMethods
88 end
9-
9+
1010 module ClassMethods
1111 def inherited ( subclass )
12- subclass . matestack_app ( @matestack_app )
12+ subclass . matestack_layout ( @matestack_layout )
1313 super
1414 end
15-
16- def matestack_app ( app = nil )
17- @matestack_app = app ? app : @matestack_app
15+
16+ def matestack_layout ( layout = nil )
17+ @matestack_layout = layout ? layout : @matestack_layout
1818 end
1919 end
20-
20+
2121 def render ( *args )
2222 setup_context
2323 if args . first . is_a? ( Class ) && args . first . ancestors . include? ( Base )
@@ -30,62 +30,62 @@ def render(*args)
3030 end
3131
3232 options = args . second || { }
33- app = options . delete ( :matestack_app ) || self . class . matestack_app
33+ layout = options . delete ( :matestack_layout ) || self . class . matestack_layout
3434 page = args . first
3535
3636 if controller_layout == false
37- layout = app ? app . layout : false
37+ root_layout = layout ? layout . layout : false
3838 else
3939 if controller_layout . nil?
40- layout = "application"
40+ root_layout = "application"
4141 else
42- layout = controller_layout
42+ root_layout = controller_layout
4343 end
4444 end
45-
46- if app && params [ :only_page ] . nil? && params [ :component_key ] . nil? && params [ :component_class ] . nil?
47- render_app app , page , options , layout
45+
46+ if layout && params [ :only_page ] . nil? && params [ :component_key ] . nil? && params [ :component_class ] . nil?
47+ render_layout layout , page , options , root_layout
4848 else
4949 if params [ :component_key ] && params [ :component_class ] . nil?
50- render_component app , page , params [ :component_key ] , options
50+ render_component layout , page , params [ :component_key ] , options
5151 elsif params [ :component_class ]
5252 if params [ :component_key ]
5353 render_component nil , params [ :component_class ] . constantize , params [ :component_key ] , JSON . parse ( params [ :public_options ] || '{}' )
54- else
54+ else
5555 render html : params [ :component_class ] . constantize . ( public_options : JSON . parse ( params [ :public_options ] || '{}' ) )
5656 end
5757 else
5858 if params [ :only_page ]
5959 render_page page , options , false
6060 else
61- render_page page , options , layout
61+ render_page page , options , root_layout
6262 end
6363 end
6464 end
6565 else
6666 super
6767 end
6868 end
69-
70- def render_app ( app , page , options , layout )
71- render html : app . new ( options ) { page . new ( options ) } . render_content . html_safe , layout : layout
69+
70+ def render_layout ( layout , page , options , root_layout )
71+ render html : layout . new ( options ) { page . new ( options ) } . render_content . html_safe , layout : root_layout
7272 end
73-
74- def render_page ( page , options , layout )
75- render html : page . new ( options ) . render_content . html_safe , layout : layout
73+
74+ def render_page ( page , options , root_layout )
75+ render html : page . new ( options ) . render_content . html_safe , layout : root_layout
7676 end
77-
78- def render_component ( app , page , component_key , options )
79- app ? app . new ( options ) { page . new ( options ) } : page . new ( options ) # create page structure in order to later access registered async components
77+
78+ def render_component ( layout , page , component_key , options )
79+ layout ? layout . new ( options ) { page . new ( options ) } : page . new ( options ) # create page structure in order to later access registered async components
8080 render html : Matestack ::Ui ::Core ::Context . async_components [ component_key ] . render_content . html_safe , layout : false
8181 end
82-
82+
8383 def setup_context
8484 Matestack ::Ui ::Core ::Context . params = self . params
8585 Matestack ::Ui ::Core ::Context . controller = ( self . class <= ActionController ::Base ) ? self : @_controller
8686 end
87-
87+
8888 end
8989 end
9090 end
91- end
91+ end
0 commit comments