... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
# Title: Render Partial Tag for Jekyll |
2 | 2 |
# Author: Brandon Mathis http://brandonmathis.com |
3 | 3 |
# Description: Import files on your filesystem into any blog post and render them inline. |
4 |
-# Note: Paths are relative to the source directory |
|
4 |
+# Note: Paths are relative to the source directory, if you import a file with yaml front matter, the yaml will be stripped out. |
|
5 | 5 |
# |
6 | 6 |
# Syntax {% render_partial path/to/file %} |
7 | 7 |
# |
... | ... |
@@ -19,6 +19,7 @@ |
19 | 19 |
# This might be useful if you want to have a page for a project's README without having |
20 | 20 |
# to duplicated the contents |
21 | 21 |
# |
22 |
+# |
|
22 | 23 |
|
23 | 24 |
require 'pathname' |
24 | 25 |
|
... | ... |
@@ -40,7 +41,11 @@ module Jekyll |
40 | 40 |
end |
41 | 41 |
|
42 | 42 |
Dir.chdir(file_path) do |
43 |
- partial = Liquid::Template.parse(file.read) |
|
43 |
+ contents = file.read |
|
44 |
+ if contents =~ /\A-{3}.+[^\A]-{3}\n(.+)/m |
|
45 |
+ contents = $1.lstrip |
|
46 |
+ end |
|
47 |
+ partial = Liquid::Template.parse(contents) |
|
44 | 48 |
context.stack do |
45 | 49 |
partial.render(context) |
46 | 50 |
end |