سؤال

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?

هل كانت مفيدة؟

المحلول 2

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

نصائح أخرى

You can use Dir.glob to find and iterate all the Markdown files in the directory.

Dir.glob("path/to/folder/*.md") do |file|
  # do what you want with file
end
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top