diff --git a/CHANGELOG.md b/CHANGELOG.md index 55986de6..78bc4f20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ master === +* Rather than applying layouts to all files which are not .txt, .css, .js, .json: the new behavior is to only default layouts to active for .html * Switch from Ruby Sass to SassC. * `relative_assets` extension overrides local `relative: false` option to stylesheet/javascript tag helpers. diff --git a/middleman-core/features/cli_init.feature b/middleman-core/features/cli_init.feature index 1eb9e840..52aa8f7b 100644 --- a/middleman-core/features/cli_init.feature +++ b/middleman-core/features/cli_init.feature @@ -57,11 +57,11 @@ Feature: Middleman CLI Then a directory named "MY_PROJECT" should exist Scenario: Create a new project using Middleman directory - When I run `middleman init MY_PROJECT -T amicus` + When I run `middleman init MY_PROJECT -T blog` Then a directory named "MY_PROJECT" should exist When I cd to "MY_PROJECT" - And the file "README.md" should contain "Amicus" - And the file ".gitignore" should not exist + And the file "Gemfile" should contain "middleman-blog" + And the file ".gitignore" should exist Scenario: Create a new project using github(user/repository) When I run `middleman init MY_PROJECT -T middleman/middleman-templates-default` interactively diff --git a/middleman-core/features/default-layout.feature b/middleman-core/features/default-layout.feature new file mode 100644 index 00000000..82fbeeff --- /dev/null +++ b/middleman-core/features/default-layout.feature @@ -0,0 +1,90 @@ +Feature: Describe which files get layouts + + Background: + Given an empty app + And a file named "config.rb" with: + """ + page "/about.html", layout: :layout2 + """ + And a file named "source/layouts/layout.erb" with: + """ + In Layout + <%= yield %> + """ + And a file named "source/layouts/layout2.erb" with: + """ + + Second Layout + <%= yield %> + + """ + And a file named "source/index.html.erb" with: + """ + In Index + """ + And a file named "source/about.html.erb" with: + """ + In About + """ + And a file named "source/style.css.scss" with: + """ + html { border: 1; } + """ + And a file named "source/style2.scss" with: + """ + html { border: 2; } + """ + And a file named "source/data.json" with: + """ + { "hello": "world" } + """ + And a file named "source/script.js" with: + """ + helloWorld(); + """ + And a file named "source/test.xml.erb" with: + """ + --- + layout: layout2 + --- + + Hi + """ + And the Server is running at "empty_app" + + Scenario: Normal Template + When I go to "/index.html" + Then I should see "In Index" + And I should see "In Layout" + + Scenario: Normal Template with override + When I go to "/about.html" + Then I should see "In About" + And I should see "Second Layout" + And I should not see "In Layout" + + Scenario: Sass + When I go to "/style.css" + Then I should see "border: 1" + And I should not see "In Layout" + + Scenario: Sass with extension + When I go to "/style2" + Then I should see "border: 2" + And I should not see "In Layout" + + Scenario: JSON + When I go to "/data.json" + Then I should see "hello" + And I should not see "In Layout" + + Scenario: JS + When I go to "/script.js" + Then I should see "helloWorld()" + And I should not see "In Layout" + + Scenario: XML + When I go to "/test.xml" + Then I should see "Hi" + And I should see "Second Layout" + diff --git a/middleman-core/lib/middleman-core/sitemap/resource.rb b/middleman-core/lib/middleman-core/sitemap/resource.rb index dfd7e46b..cb054460 100644 --- a/middleman-core/lib/middleman-core/sitemap/resource.rb +++ b/middleman-core/lib/middleman-core/sitemap/resource.rb @@ -134,7 +134,7 @@ module Middleman # Certain output file types don't use layouts unless opts.key?(:layout) - opts[:layout] = false if %w(.js .json .css .txt).include?(ext) + opts[:layout] = false if ext != '.html' end renderer = ::Middleman::TemplateRenderer.new(@app, file_descriptor[:full_path].to_s)