Module: ActionView::Helpers::NestedLayoutsHelper

Defined in:
lib/nested_layouts.rb

Instance Method Summary collapse

Instance Method Details

#inside_inline_layout(template_content, &block) ⇒ Object

Wrap part of the template into inline layout. Same as inside_layout but takes layout template content rather than layout template name.



15
16
17
18
# File 'lib/nested_layouts.rb', line 15

def inside_inline_layout(template_content, &block)
  @template.instance_variable_set('@content_for_layout', capture(&block))
  concat( @template.render(:inline => template_content) )
end

#inside_layout(layout, &block) ⇒ Object

Wrap part of the template into layout. All layout files must be in app/views/layouts.



7
8
9
10
11
# File 'lib/nested_layouts.rb', line 7

def inside_layout(layout, &block)
  layout_template = @template.view_paths.find_template(layout.to_s =~ /layouts\// ? layout : "layouts/#{layout}", :html)
  @template.instance_variable_set('@content_for_layout', capture(&block))
  concat( layout_template.render_template(@template) )
end