From 0c29fd4abf36cda84a12c3a644d51db060feb714 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 26 Jan 2016 13:21:39 -0800 Subject: [PATCH] Make templates extensions with layouts configurable --- CHANGELOG.md | 1 + middleman-core/lib/middleman-core/application.rb | 6 +++++- middleman-core/lib/middleman-core/sitemap/resource.rb | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ce7548e..6e0e55c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ master * Show an error message when git CLI is not available. #1765 * Correctly show file names of GZIP'ed assets. #1364 * Build file output is not parallel-ized! Use `middleman build --no-parallel` to disable. +* Make template file extensions that get layouts by default configurable via `config[:extensions_with_layout]` # 4.0.0 diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 9000db79..b0dbdb48 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -149,9 +149,13 @@ module Middleman define_setting :http_prefix, '/', 'Default prefix for building paths' # Default layout name - # @return [String, Symbold] + # @return [String] define_setting :layout, :_auto_layout, 'Default layout name' + # Which file extensions have a layout by default. + # @return [Array.] + define_setting :extensions_with_layout, %w(.html .xhtml .php), 'Which file extensions have a layout by default.' + # Default string encoding for templates and output. # @return [String] define_setting :encoding, 'utf-8', 'Default string encoding for templates and output' diff --git a/middleman-core/lib/middleman-core/sitemap/resource.rb b/middleman-core/lib/middleman-core/sitemap/resource.rb index 5d7b9969..b7b0e063 100644 --- a/middleman-core/lib/middleman-core/sitemap/resource.rb +++ b/middleman-core/lib/middleman-core/sitemap/resource.rb @@ -138,7 +138,7 @@ module Middleman locs[:current_path] ||= destination_path # Certain output file types don't use layouts - opts[:layout] = false if !opts.key?(:layout) && ext != '.html' + opts[:layout] = false if !opts.key?(:layout) && !@app.config.extensions_with_layout.include?(ext) renderer = ::Middleman::TemplateRenderer.new(@app, file_descriptor[:full_path].to_s) renderer.render(locs, opts)