Skip to content

Instantly share code, notes, and snippets.

@killercup
Created March 28, 2012 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killercup/2229722 to your computer and use it in GitHub Desktop.
Save killercup/2229722 to your computer and use it in GitHub Desktop.
Extensions for Bonsai, http://tinytree.info/
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