rubysinatrardiscount

Find every file in a directory and render them all using rdiscount


I've got a directory called "posts" which is filled with .md files. Right now rdiscount renders only one file (one.md), then puts the product into a variable (@content). Because this is done issuing...

@content = markdown(:one)

...I'm really confused as to how to make ruby 1) find every file in the directory and 2) render everything using rdiscount. Any ideas?


Solution

  • To extend @Simone Carletti's answer, in order to answer part 2 of your question:

    @content = ""
    Dir.glob("path/to/folder/*.md") do |file|
      @content << markdown(file)
    end