layouts_dir is now configurable. Closes #899
This commit is contained in:
parent
149f6ffa5b
commit
d0cd3e3cf9
8 changed files with 49 additions and 3 deletions
|
@ -12,6 +12,7 @@
|
|||
3.1.0.rc.2
|
||||
===
|
||||
|
||||
* `layouts_dir` is now configurable
|
||||
* Custom template classes can now override the file used for creating the project Gemfile.
|
||||
* Add an "empty" template that produces the minimum necessary structure for a Middleman project.
|
||||
* Fix ignoring layouts from the sitemap when the source directory has been set to something other than 'source'. #896
|
||||
|
|
30
middleman-core/features/layouts_dir.feature
Normal file
30
middleman-core/features/layouts_dir.feature
Normal file
|
@ -0,0 +1,30 @@
|
|||
Feature: Layouts dir
|
||||
Scenario: Find layouts in a custom layouts dir
|
||||
Given a fixture app "layouts-dir-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
set :layouts_dir, 'layouts2'
|
||||
"""
|
||||
And the Server is running
|
||||
When I go to "/index.html"
|
||||
Then I should see "contents of the custom layout"
|
||||
|
||||
Scenario: Find layouts in a nested custom layouts dir
|
||||
Given a fixture app "layouts-dir-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
set :layouts_dir, 'nested/layouts2'
|
||||
"""
|
||||
And the Server is running
|
||||
When I go to "/index.html"
|
||||
Then I should see "contents of the nested layout"
|
||||
|
||||
Scenario: Find layouts in the default layouts dir
|
||||
Given a fixture app "layouts-dir-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
"""
|
||||
And the Server is running
|
||||
When I go to "/index.html"
|
||||
Then I should see "contents of the layout"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
Hello
|
|
@ -0,0 +1,3 @@
|
|||
contents of the layout
|
||||
|
||||
<%= yield %>
|
|
@ -0,0 +1,3 @@
|
|||
contents of the custom layout
|
||||
|
||||
<%= yield %>
|
|
@ -0,0 +1,3 @@
|
|||
contents of the nested layout
|
||||
|
||||
<%= yield %>
|
|
@ -97,6 +97,10 @@ module Middleman
|
|||
# @return [String]
|
||||
config.define_setting :partials_dir, "", 'Location of partials within source'
|
||||
|
||||
# Location of layouts within source. Used by renderers.
|
||||
# @return [String]
|
||||
config.define_setting :layouts_dir, "layouts", 'Location of layouts within source'
|
||||
|
||||
# Where to build output files
|
||||
# @return [String]
|
||||
config.define_setting :build_dir, "build", 'Where to build output files'
|
||||
|
|
|
@ -153,7 +153,7 @@ module Middleman
|
|||
content = render_individual_file(path, locs, opts, context)
|
||||
path = File.basename(path, File.extname(path))
|
||||
rescue LocalJumpError
|
||||
raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/layouts."
|
||||
raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/#{layout_dir}."
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -369,7 +369,7 @@ module Middleman
|
|||
|
||||
# Check layouts folder
|
||||
if !layout_path
|
||||
layout_path, layout_engine = resolve_template(File.join("layouts", name.to_s), :preferred_engine => preferred_engine)
|
||||
layout_path, layout_engine = resolve_template(File.join(config[:layouts_dir], name.to_s), :preferred_engine => preferred_engine)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -380,7 +380,7 @@ module Middleman
|
|||
|
||||
# Check layouts folder, no preference
|
||||
if !layout_path
|
||||
layout_path, layout_engine = resolve_template(File.join("layouts", name.to_s))
|
||||
layout_path, layout_engine = resolve_template(File.join(config[:layouts_dir], name.to_s))
|
||||
end
|
||||
|
||||
# Return the path
|
||||
|
|
Loading…
Reference in a new issue