Module: MuchRails::Layout::Helper
- Defined in:
- lib/much-rails/layout/helper.rb
Instance Method Summary collapse
-
#much_rails_render_layouts(view_model, &content) ⇒ Object
This is used to render layouts.
Instance Method Details
#much_rails_render_layouts(view_model, &content) ⇒ Object
This is used to render layouts. It is designed to be used in the Rails layout template to render the nested layouts.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/much-rails/layout/helper.rb', line 9 def much_rails_render_layouts(view_model, &content) unless view_model.is_a?(MuchRails::Layout) raise( TypeError, "A View Model that mixes in MuchRails::Layout expected; "\ "got #{view_model.class}.", ) end view_model .layouts .reverse .reduce(content){ |render_proc, template_path| ->{ render(File.join("layouts", template_path), &render_proc) } } .call end |