class Middleman::TemplateRenderer
def fetch_layout(engine, opts)
def fetch_layout(engine, opts) # The layout name comes from either the system default or the options local_layout = opts.key?(:layout) ? opts[:layout] : @app.config[:layout] return unless local_layout # Look for engine-specific options engine_options = @app.config.respond_to?(engine) ? @app.config.send(engine) : {} # The engine for the layout can be set in options, engine_options or passed # into this method layout_engine = if opts.key?(:layout_engine) opts[:layout_engine] elsif engine_options.key?(:layout_engine) engine_options[:layout_engine] else engine end # Automatic mode if local_layout == :_auto_layout # Look for :layout of any extension # If found, use it. If not, continue locate_layout(:layout, layout_engine) else # Look for specific layout # If found, use it. If not, error. if layout_file = locate_layout(local_layout, layout_engine) layout_file else raise ::Middleman::TemplateRenderer::TemplateNotFound, "Could not locate layout: #{local_layout}" end end end