diff options
author | Ryan Daigle <ryan.daigle@gmail.com> | 2010-01-24 21:00:51 -0500 |
---|---|---|
committer | B Mathis <brandon@imathis.com> | 2010-02-05 09:47:13 -0600 |
commit | 572be10d7d6223c6bbfbf96e58e122a7de7bc509 (patch) | |
tree | fd031e4af8730fbc7ced21d2d803d7979496a7c6 | |
parent | c41b9e89ae88d50d8de43dd86d338c6d84483089 (diff) | |
download | my_new_personal_website-572be10d7d6223c6bbfbf96e58e122a7de7bc509.tar.xz my_new_personal_website-572be10d7d6223c6bbfbf96e58e122a7de7bc509.zip |
Add partial support with a HAML approved version of jekyll's include
-rw-r--r-- | source/_helpers.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source/_helpers.rb b/source/_helpers.rb index 48e40b0d..b1714569 100644 --- a/source/_helpers.rb +++ b/source/_helpers.rb @@ -159,6 +159,27 @@ module Helpers def style_amp(input) input.gsub(" & "," <span class='amp'>&</span> ") end + + module PartialsHelper + + # A very hackish way to handle partials. We'll go with it till it breaks... + def include(partial_name) + file_ext = partial_name[(partial_name.index('.') + 1)..partial_name.length] + contents = IO.read("_includes/#{partial_name}") + case file_ext + when 'haml' + Haml::Engine.new(contents).render(binding) + when 'textile' + RedCloth.new(contents).to_html + when 'markdown' + RDiscount.new(contents).to_html + else + contents + end + end + end + + include PartialsHelper end class String |