Markdown as a static templating language for Rails views and partials - joliss/markdown-rails.
- I want users to type in Markdown text in a textarea and when they post it, I display the corresponding html. I read that Rails used to have a markdown method or similarly called method, that you could just call on that field in the ERB file: <%=
- Markdown 是时下很流行的一种标记语言。 可以很简便的生成 html 代码,github 的 README 就是用这种形式显示再代码目录的下面。 Ruby/Rails 借助繁多的 Gem,可以迅速的就做好 markdown 的支持,顺道包含对代码高亮的支持。 Gem 太多,实现方法也太多。.
In my Rails apps, I have a lot of static prose, and that prose tends to bewritten in HTML. As a result, it’s cumbersome to edit.
Markdown would be much better suited for prose. However, Rails does not support.html.md
views out of the box.
As described by @tjwallace, thereis a simple workaround – use HAML’s:markdown
filter:
Still, this leaves your Markdown files indented. I thought there is no reasonwhy Rails shouldn’t support plain .html.md
files.
So I wrote up a simple markdown-rails gem. Check it out:
Rails Markdown Download
Rails Markdown Gem
One shortcoming is, it doesn’t support embedded Ruby code (like HAML’s:markdown
filter with #{exp}
). I’d love to add this at some point, but I’mnot sure about the best approach. See the comments and the Limitations sectionin the README.