diff options
author | Brandon Mathis <brandon@imathis.com> | 2011-07-22 11:46:55 -0400 |
---|---|---|
committer | Brandon Mathis <brandon@imathis.com> | 2011-07-22 11:48:36 -0400 |
commit | ba0e5ef4a38a3c06b8bcf4af6518cd00665dacb2 (patch) | |
tree | 1bcf3515f7e4bbf555767064e606acd0491c9e94 /plugins/render_partial.rb | |
parent | 12aed03eea27534168a1a5edb7c484fdf24b5937 (diff) | |
download | my_new_personal_website-ba0e5ef4a38a3c06b8bcf4af6518cd00665dacb2.tar.xz my_new_personal_website-ba0e5ef4a38a3c06b8bcf4af6518cd00665dacb2.zip |
Render partial now automatically stirps out yaml front matter
Diffstat (limited to 'plugins/render_partial.rb')
-rw-r--r-- | plugins/render_partial.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/render_partial.rb b/plugins/render_partial.rb index 96de97ea..3cb74c21 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 |