From d64fd1e8fea9de400109cf0f3f181d590e67293f Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Fri, 12 Apr 2013 17:37:16 +0200 Subject: [PATCH] expose file path relative to source dir to liquid Fixes #633. --- lib/jekyll/page.rb | 3 ++- lib/jekyll/post.rb | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) 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..45de5267 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, @name).sub(/\A\//, '') }) end # Returns the shorthand String identifier of this Post.