Guest User

Untitled

a guest
Jun 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. module ActionView #:nodoc:
  2. module Helpers #:nodoc:
  3. module NestedLayoutsHelper
  4. # Wrap part of the template into layout.
  5. #
  6. # If layout doesn't contain '/' then corresponding layout template
  7. # is searched in default folder ('app/views/layouts'), otherwise
  8. # it is searched relative to controller's template root directory
  9. # ('app/views/' by default).
  10. def inside_layout(layout, &block)
  11. layout = layout.to_s
  12. layout = layout.include?('/') ? layout : "layouts/#{layout}"
  13. @template.instance_variable_set('@content_for_layout', capture(&block))
  14. concat(
  15. @template.render(:file => layout, :use_full_path => true)
  16. )
  17. end
  18.  
  19. # Wrap part of the template into inline layout.
  20. # Same as +inside_layout+ but takes layout template content rather than layout template name.
  21. def inside_inline_layout(template_content, &block)
  22. @template.instance_variable_set('@content_for_layout', capture(&block))
  23. concat(@template.render(:inline => template_content))
  24. end
  25. end
  26. end
  27. end
Add Comment
Please, Sign In to add comment