diff --git a/features/create_sites.feature b/features/create_sites.feature index 16e733b1..a25a0d32 100644 --- a/features/create_sites.feature +++ b/features/create_sites.feature @@ -44,6 +44,17 @@ Feature: Create sites Then the _site directory should exist And I should see "Post Layout:

The only winning move is not to play.

" 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:

The only winning move is not to play.

" in "_site/2009/03/27/wargames.html" + Scenario: Basic site with layouts, pages, posts and files Given I have a _layouts directory And I have a page layout that contains "Page {{ page.title }}: {{ content }}" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 3604f523..4e11aad9 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -38,7 +38,12 @@ Given /^I have an? (.*) (layout|theme) that contains "(.*)"$/ do |name, type, te else '_theme' 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) end end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 5cad11c8..04fc77e1 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -122,7 +122,7 @@ module Jekyll base = File.join(self.source, self.config['layouts']) return unless File.exists?(base) entries = [] - Dir.chdir(base) { entries = filter_entries(Dir['*.*']) } + Dir.chdir(base) { entries = filter_entries(Dir['**/*.*']) } entries.each do |f| name = f.split(".")[0..-2].join(".") diff --git a/test/source/_layouts/post/simple.html b/test/source/_layouts/post/simple.html new file mode 100644 index 00000000..cd4f5999 --- /dev/null +++ b/test/source/_layouts/post/simple.html @@ -0,0 +1 @@ +<<< {{ content }} >>> diff --git a/test/test_site.rb b/test/test_site.rb index 0ff9185f..4deb5645 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -156,7 +156,7 @@ class TestSite < Test::Unit::TestCase should "read layouts" do @site.read_layouts - assert_equal ["default", "simple"].sort, @site.layouts.keys.sort + assert_equal ["default", "simple", "post/simple"].sort, @site.layouts.keys.sort end should "read posts" do