diff --git a/features/post_data.feature b/features/post_data.feature
index 61732f90..6ff48d6c 100644
--- a/features/post_data.feature
+++ b/features/post_data.feature
@@ -153,6 +153,21 @@ Feature: Post data
And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2009/03/27/star-wars.html"
And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2013/03/17/star-trek.html"
+ Scenario Outline: Use post.path variable
+ Given I have a
/_posts directory
+ And I have the following post in "":
+ | title | type | date | content |
+ | my-post | html | 4/12/2013 | Source path: {{ page.path }} |
+ When I run jekyll
+ Then the _site directory should exist
+ And I should see "Source path: _posts/2013-04-12-my-post.html" in "_site//2013/04/12/my-post.html"
+
+ Examples:
+ | dir | path_prefix |
+ | . | |
+ | dir | dir/ |
+ | dir/nested | dir/nested/ |
+
Scenario: Disable a post from being published
Given I have a _posts directory
And I have an "index.html" file that contains "Published!"
diff --git a/features/site_data.feature b/features/site_data.feature
index 0a0b1a7e..36b0f861 100644
--- a/features/site_data.feature
+++ b/features/site_data.feature
@@ -9,6 +9,19 @@ Feature: Site data
Then the _site directory should exist
And I should see "Contact: email@me.com" in "_site/contact.html"
+ Scenario Outline: Use page.path variable in a page
+ Given I have a directory
+ And I have a "" page that contains "Source path: {{ page.path }}"
+ When I run jekyll
+ Then the _site directory should exist
+ And I should see "Source path: " in "_site/"
+
+ Examples:
+ | dir | path |
+ | . | index.html |
+ | dir | dir/about.html |
+ | dir/nested | dir/nested/page.html |
+
Scenario: Use site.time variable
Given I have an "index.html" page that contains "{{ site.time }}"
When I run jekyll
diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb
index 0de5e254..c56396a4 100644
--- a/lib/jekyll/page.rb
+++ b/lib/jekyll/page.rb
@@ -124,7 +124,8 @@ module Jekyll
def to_liquid
self.data.deep_merge({
"url" => self.url,
- "content" => self.content })
+ "content" => self.content,
+ "path" => File.join(@dir, @name).sub(/\A\//, '') })
end
# Obtain destination path.
diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb
index e040fb02..1da37001 100644
--- a/lib/jekyll/post.rb
+++ b/lib/jekyll/post.rb
@@ -33,6 +33,7 @@ module Jekyll
# Returns the new Post.
def initialize(site, source, dir, name)
@site = site
+ @dir = dir
@base = self.containing_dir(source, dir)
@name = name
@@ -285,7 +286,8 @@ module Jekyll
"previous" => self.previous,
"tags" => self.tags,
"content" => self.content,
- "excerpt" => self.excerpt })
+ "excerpt" => self.excerpt,
+ "path" => File.join(@dir, '_posts', @name).sub(/\A\//, '') })
end
# Returns the shorthand String identifier of this Post.