fix layouts with implied extensions

This commit is contained in:
Thomas Reynolds 2013-06-24 13:39:14 -07:00
parent 3399ee207e
commit 37752dc291
5 changed files with 24 additions and 5 deletions

View file

@ -1,3 +1,8 @@
3.1.x
===
* Fix for implied extensions getting a layout. (Mentioned in #901)
3.1.2
===

View file

@ -12,12 +12,16 @@ Feature: More default extensions
Then I should see "HELLO"
When I go to "/javascripts/app.js"
Then I should see "derp"
Then I should not see "I am in the layout"
When I go to "/stylesheets/style.css"
Then I should see "section"
Then I should not see "I am in the layout"
When I go to "/stylesheets/style2.css"
Then I should see "section"
Then I should not see "I am in the layout"
When I go to "/stylesheets/style3.css"
Then I should see "color"
Then I should not see "I am in the layout"
Scenario: Default extensions build
Given a fixture app "more-implied-extensions-app"
@ -37,6 +41,10 @@ Feature: More default extensions
And the file "test3.html" should contain "Howdy"
And the file "test4.html" should contain "HELLO"
And the file "javascripts/app.js" should contain "derp"
And the file "javascripts/app.js" should not contain "I am in the layout"
And the file "stylesheets/style.css" should contain "section"
And the file "stylesheets/style.css" should not contain "I am in the layout"
And the file "stylesheets/style2.css" should contain "section"
And the file "stylesheets/style3.css" should contain "color"
And the file "stylesheets/style2.css" should not contain "I am in the layout"
And the file "stylesheets/style3.css" should contain "color"
And the file "stylesheets/style3.css" should not contain "I am in the layout"

View file

@ -0,0 +1,3 @@
I am in the layout
<%= yield %>

View file

@ -154,11 +154,8 @@ module Middleman
end
end
# Certain output file types don't use layouts
needs_layout = !%w(.js .json .css .txt).include?(File.extname(path))
# If we need a layout and have a layout, use it
if needs_layout && layout_path = fetch_layout(engine, opts)
if layout_path = fetch_layout(engine, opts)
content = render_individual_file(layout_path, locs, opts, context) { content }
end

View file

@ -141,6 +141,12 @@ module Middleman
blocks << block if block_given?
app.current_path ||= self.destination_path
# Certain output file types don't use layouts
if !opts.has_key?(:layout)
opts[:layout] = false if %w(.js .json .css .txt).include?(self.ext)
end
app.render_template(source_file, locs, opts, blocks)
end
end