Change no-layout to the default, except for .html

This commit is contained in:
Thomas Reynolds 2015-11-11 12:58:07 -08:00
parent 90490d696f
commit 684a80c906
4 changed files with 95 additions and 4 deletions

View file

@ -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.

View file

@ -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

View file

@ -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:
"""
<root>
<title>Second Layout</title>
<%= yield %>
</root>
"""
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
---
<test>Hi</test>
"""
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 "<test>Hi</test>"
And I should see "<title>Second Layout</title>"

View file

@ -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)