diff --git a/lib/jekyll/rendering.rb b/lib/jekyll/rendering.rb
index d269551..3621cd4 100644
--- a/lib/jekyll/rendering.rb
+++ b/lib/jekyll/rendering.rb
@@ -153,18 +153,22 @@ module Helpers
# call-seq:
# include_file file => aString
- # include_file file, binding => aString
#
- # Includes file +file+ from _includes directory rendered
- # as ERB template. Uses optional +binding+ if provided.
- def include_file(file, binding = binding)
- Dir.chdir(File.join(site.source, '_includes')) {
- @choices ||= Dir['**/*'].reject { |x| File.symlink?(x) }
-
- if @choices.include?(file = file.strip)
+ # Includes file +file+ from _includes directory, or current
+ # directory if +current+ is true, rendered as ERB template. Uses
+ # optional +binding+ if provided.
+ def include_file(file, current = false, binding = binding)
+ dir = current ? File.dirname(page.url) : '_includes'
+
+ Dir.chdir(File.join(site.source, dir)) {
+ @choices ||= Hash.new { |h, k|
+ h[k] = Dir['**/*'].reject { |x| File.symlink?(x) }
+ }
+
+ if @choices[dir].include?(file = file.strip)
render(File.read(file), binding)
else
- "Included file '#{file}' not found in _includes directory"
+ "[Included file `#{file}' not found in `#{dir}'.]"
end
}
end