Merge pull request #951 from maul-esel/liquid-file-path
Expose file path to Liquid
This commit is contained in:
commit
92db4ed89f
|
@ -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/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"
|
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 <dir>/_posts directory
|
||||||
|
And I have the following post in "<dir>":
|
||||||
|
| 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: <path_prefix>_posts/2013-04-12-my-post.html" in "_site/<dir>/2013/04/12/my-post.html"
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| dir | path_prefix |
|
||||||
|
| . | |
|
||||||
|
| dir | dir/ |
|
||||||
|
| dir/nested | dir/nested/ |
|
||||||
|
|
||||||
Scenario: Disable a post from being published
|
Scenario: Disable a post from being published
|
||||||
Given I have a _posts directory
|
Given I have a _posts directory
|
||||||
And I have an "index.html" file that contains "Published!"
|
And I have an "index.html" file that contains "Published!"
|
||||||
|
|
|
@ -9,6 +9,19 @@ Feature: Site data
|
||||||
Then the _site directory should exist
|
Then the _site directory should exist
|
||||||
And I should see "Contact: email@me.com" in "_site/contact.html"
|
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 <dir> directory
|
||||||
|
And I have a "<path>" page that contains "Source path: {{ page.path }}"
|
||||||
|
When I run jekyll
|
||||||
|
Then the _site directory should exist
|
||||||
|
And I should see "Source path: <path>" in "_site/<path>"
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| dir | path |
|
||||||
|
| . | index.html |
|
||||||
|
| dir | dir/about.html |
|
||||||
|
| dir/nested | dir/nested/page.html |
|
||||||
|
|
||||||
Scenario: Use site.time variable
|
Scenario: Use site.time variable
|
||||||
Given I have an "index.html" page that contains "{{ site.time }}"
|
Given I have an "index.html" page that contains "{{ site.time }}"
|
||||||
When I run jekyll
|
When I run jekyll
|
||||||
|
|
|
@ -124,7 +124,8 @@ module Jekyll
|
||||||
def to_liquid
|
def to_liquid
|
||||||
self.data.deep_merge({
|
self.data.deep_merge({
|
||||||
"url" => self.url,
|
"url" => self.url,
|
||||||
"content" => self.content })
|
"content" => self.content,
|
||||||
|
"path" => File.join(@dir, @name).sub(/\A\//, '') })
|
||||||
end
|
end
|
||||||
|
|
||||||
# Obtain destination path.
|
# Obtain destination path.
|
||||||
|
|
|
@ -33,6 +33,7 @@ module Jekyll
|
||||||
# Returns the new Post.
|
# Returns the new Post.
|
||||||
def initialize(site, source, dir, name)
|
def initialize(site, source, dir, name)
|
||||||
@site = site
|
@site = site
|
||||||
|
@dir = dir
|
||||||
@base = self.containing_dir(source, dir)
|
@base = self.containing_dir(source, dir)
|
||||||
@name = name
|
@name = name
|
||||||
|
|
||||||
|
@ -285,7 +286,8 @@ module Jekyll
|
||||||
"previous" => self.previous,
|
"previous" => self.previous,
|
||||||
"tags" => self.tags,
|
"tags" => self.tags,
|
||||||
"content" => self.content,
|
"content" => self.content,
|
||||||
"excerpt" => self.excerpt })
|
"excerpt" => self.excerpt,
|
||||||
|
"path" => File.join(@dir, '_posts', @name).sub(/\A\//, '') })
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the shorthand String identifier of this Post.
|
# Returns the shorthand String identifier of this Post.
|
||||||
|
|
Loading…
Reference in New Issue