Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow a custom 'layouts' directory #566

Merged
merged 1 commit into from

2 participants

Tom Bell Tom Preston-Werner
Tom Bell
  • Add 'layouts' option to change the dir from '_layouts' to anything relative to the source directory
  • Add cucumber scenario for testing an alternative directory '_theme'
  • Closes #563
Tom Bell tombell Allow a custom 'layouts' directory
* Add 'layouts' option to change the dir from '_layouts' to anything relative
  to the source directory
* Add cucumber scenario for testing an alternative directory '_theme'
* Closes #563
df2ad2a
Tom Preston-Werner
Owner

Looks good, will merge.

Tom Preston-Werner mojombo merged commit df2ad2a into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 31, 2012
  1. Tom Bell

    Allow a custom 'layouts' directory

    tombell authored
    * Add 'layouts' option to change the dir from '_layouts' to anything relative
      to the source directory
    * Add cucumber scenario for testing an alternative directory '_theme'
    * Closes #563
This page is out of date. Refresh to see the latest.
21 features/site_configuration.feature
View
@@ -143,3 +143,24 @@ Feature: Site configuration
Then the _site directory should exist
And I should see ".DS_Store" in "_site/.gitignore"
And the "_site/.htaccess" file should not exist
+
+ Scenario: Using a different layouts directory
+ Given I have a _theme directory
+ And I have a page theme that contains "Page Layout: {{ site.posts.size }} on {{ site.time | date: "%Y-%m-%d" }}"
+ And I have a post theme that contains "Post Layout: {{ content }}"
+ And I have an "index.html" page with layout "page" that contains "site index page"
+ And I have a configuration file with:
+ | key | value |
+ | time | 2010-01-01 |
+ | future | true |
+ | layouts | _theme |
+ And I have a _posts directory
+ And I have the following posts:
+ | title | date | layout | content |
+ | entry1 | 12/31/2007 | post | content for entry1. |
+ | entry2 | 01/31/2020 | post | content for entry2. |
+ When I run jekyll
+ Then the _site directory should exist
+ And I should see "Page Layout: 2 on 2010-01-01" in "_site/index.html"
+ And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
+ And I should see "Post Layout: <p>content for entry2.</p>" in "_site/2020/01/31/entry2.html"
7 features/step_definitions/jekyll_steps.rb
View
@@ -39,6 +39,13 @@
end
end
+Given /^I have a (.*) theme that contains "(.*)"$/ do |layout, text|
+ File.open(File.join('_theme', layout + '.html'), 'w') do |f|
+ f.write(text)
+ f.close
+ end
+end
+
Given /^I have an? (.*) directory$/ do |dir|
FileUtils.mkdir_p(dir)
end
1  lib/jekyll.rb
View
@@ -59,6 +59,7 @@ module Jekyll
'source' => Dir.pwd,
'destination' => File.join(Dir.pwd, '_site'),
'plugins' => File.join(Dir.pwd, '_plugins'),
+ 'layouts' => '_layouts',
'future' => true,
'lsi' => false,
2  lib/jekyll/site.rb
View
@@ -106,7 +106,7 @@ def read
#
# Returns nothing.
def read_layouts(dir = '')
- base = File.join(self.source, dir, "_layouts")
+ base = File.join(self.source, dir, self.config['layouts'])
return unless File.exists?(base)
entries = []
Dir.chdir(base) { entries = filter_entries(Dir['*.*']) }
Something went wrong with that request. Please try again.