Render partial now automatically stirps out yaml front matter

This commit is contained in:
Brandon Mathis 2011-07-22 11:46:55 -04:00
parent 12aed03eea
commit ba0e5ef4a3
1 changed files with 7 additions and 2 deletions

View File

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