module Padrino::Rendering::ClassMethods

def fetch_layout_path(given_layout=nil)

Parameters:
  • given_layout (Symbol, nil) --
def fetch_layout_path(given_layout=nil)
  layout_name = given_layout || @layout || :application
  @_cached_layout ||= {}
  cached_layout_path = @_cached_layout[layout_name]
  return cached_layout_path if cached_layout_path
  has_layout_at_root = Dir["#{views}/#{layout_name}.*"].any?
  layout_path = has_layout_at_root ? layout_name.to_sym : File.join('layouts', layout_name.to_s).to_sym
  @_cached_layout[layout_name] = layout_path unless reload_templates?
  layout_path
end