Created
March 28, 2012 19:33
-
-
Save killercup/2229722 to your computer and use it in GitHub Desktop.
Extensions for Bonsai, http://tinytree.info/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Bonsai | |
class Page | |
def markdown(content) | |
# Render the markdown file with the name `content` | |
# that is in the folder of the current page. | |
# Also replace `<%= path %>` with the page's directory path. | |
content = File.read File.join(directory, content.strip) | |
to_markdown content.gsub('<%= path %>', permalink) | |
end | |
def find(permalink) | |
# Select a page by permalink. | |
self.class.find permalink | |
end | |
def import(file) | |
# use in ERB | |
Tilt.new("templates/#{file}.html.erb").render(self, to_hash) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment