Module: LeanWeb::ControllerMixins::RenderWithLayout
- Defined in:
- contrib/lib/leanweb/controller_mixins/render_with_layout.rb
Overview
#render_with_layout for LeanWeb::Controller with ERB, HAML, Tilt::EmacsOrg and Redcarpet Markdown support.
Instance Method Summary collapse
-
#default_static_action(view_path) ⇒ Object
Render response for missing static action methods.
-
#render_with_layout(path, locals: {}, title: nil, head: nil, layout: 'layout.haml', sub_layout: nil, options: nil) { ... } ⇒ Object
Render a response with a layout.
Instance Method Details
#default_static_action(view_path) ⇒ Object
Render response for missing static action methods. Called from Route#respond.
59 60 61 |
# File 'contrib/lib/leanweb/controller_mixins/render_with_layout.rb', line 59 def default_static_action(view_path) render_with_layout(view_path) end |
#render_with_layout(path, locals: {}, title: nil, head: nil, layout: 'layout.haml', sub_layout: nil, options: nil) { ... } ⇒ Object
Render a response with a layout.
Depending on the path
file contents and options @content_for
might
be filled. These contents must be inserted on the head
or body
of
your layout file.
All paths used on parameters can be relative to VIEW_PATH or absolute.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'contrib/lib/leanweb/controller_mixins/render_with_layout.rb', line 41 def render_with_layout( # rubocop:disable Metrics/ParameterLists path, locals: {}, title: nil, head: nil, layout: 'layout.haml', sub_layout: nil, options: nil, &block ) @content_for[:title] = title unless title.nil? content = render_by_extension(path, locals, sub_layout, , &block) prepare_head(**head) unless head.nil? render_response(layout, locals, 'text/html'){ content } end |