winton / stasis

Static sites made powerful
http://stasis.me
MIT License
676 stars 56 forks source link

markdown + erb? #82

Open alexdean opened 11 years ago

alexdean commented 11 years ago

I'd like to be able to author blog posts in markdown, but sprinkle in a few helper calls here and there. Does stasis support any way to embed some ruby snippets in a markdown file?

frank06 commented 11 years ago

I use files with the .html.md extension and the following in my controller.rb:

# preprocess markdown files through ERB first, in order to use helpers, etc

before /\.md$/ do

  template_erb = Tilt::ERBTemplate.new(_stasis.path)
  out = template_erb.render(self)

  template_md = Tilt['md'].new{ out }
  instead template_md.render(self)

end