Merge pull request #1622 from blackjid/master

enable the use of folders inside the _layout path
This commit is contained in:
Matt Rogers 2013-10-10 18:38:42 -07:00
commit e3f6d860a2
5 changed files with 20 additions and 3 deletions

View File

@ -44,6 +44,17 @@ Feature: Create sites
Then the _site directory should exist Then the _site directory should exist
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html" And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
Scenario: Basic site with layout inside a subfolder and a post
Given I have a _layouts directory
And I have a _posts directory
And I have the following posts:
| title | date | layout | content |
| Wargames | 2009-03-27 | post/simple | The only winning move is not to play. |
And I have a post/simple layout that contains "Post Layout: {{ content }}"
When I run jekyll
Then the _site directory should exist
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
Scenario: Basic site with layouts, pages, posts and files Scenario: Basic site with layouts, pages, posts and files
Given I have a _layouts directory Given I have a _layouts directory
And I have a page layout that contains "Page {{ page.title }}: {{ content }}" And I have a page layout that contains "Page {{ page.title }}: {{ content }}"

View File

@ -38,7 +38,12 @@ Given /^I have an? (.*) (layout|theme) that contains "(.*)"$/ do |name, type, te
else else
'_theme' '_theme'
end end
File.open(File.join(folder, name + '.html'), 'w') do |f| destination_file = File.join(folder, name + '.html')
destination_path = File.dirname(destination_file)
unless File.exist?(destination_path)
FileUtils.mkdir_p(destination_path)
end
File.open(destination_file, 'w') do |f|
f.write(text) f.write(text)
end end
end end

View File

@ -122,7 +122,7 @@ module Jekyll
base = File.join(self.source, self.config['layouts']) base = File.join(self.source, self.config['layouts'])
return unless File.exists?(base) return unless File.exists?(base)
entries = [] entries = []
Dir.chdir(base) { entries = filter_entries(Dir['*.*']) } Dir.chdir(base) { entries = filter_entries(Dir['**/*.*']) }
entries.each do |f| entries.each do |f|
name = f.split(".")[0..-2].join(".") name = f.split(".")[0..-2].join(".")

View File

@ -0,0 +1 @@
<<< {{ content }} >>>

View File

@ -156,7 +156,7 @@ class TestSite < Test::Unit::TestCase
should "read layouts" do should "read layouts" do
@site.read_layouts @site.read_layouts
assert_equal ["default", "simple"].sort, @site.layouts.keys.sort assert_equal ["default", "simple", "post/simple"].sort, @site.layouts.keys.sort
end end
should "read posts" do should "read posts" do