How can I automatically render partials using markdown in Rails 3?

后端 未结 8 1688
小蘑菇
小蘑菇 2020-12-12 12:58

I want to have some of my partials as markdown snippets. What is the easiest way to render them using the standard rails erb templating?

Ideally, I\'d like to do so

相关标签:
8条回答
  • 2020-12-12 13:52

    I just released a markdown-rails gem, which handles .html.md views.

    You cannot chain it with Erb though -- it's only for static views and partials. To embed Ruby code, you'd have to use tjwallace's solution with :markdown.

    0 讨论(0)
  • 2020-12-12 13:59

    Not a pure markdown solution but you can use HAML filters to render markdown, as well as other markup languages.

    For example, in app/views/_my_partial.html.haml:

    :markdown
      My awesome view
      ===============
    
      Look, I can **use** #{language}!
    
    0 讨论(0)
提交回复
热议问题