From ba0e5ef4a38a3c06b8bcf4af6518cd00665dacb2 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Fri, 22 Jul 2011 11:46:55 -0400 Subject: [PATCH] Render partial now automatically stirps out yaml front matter --- plugins/render_partial.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/render_partial.rb b/plugins/render_partial.rb index 96de97e..3cb74c2 100644 --- a/plugins/render_partial.rb +++ b/plugins/render_partial.rb @@ -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