Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Piling on the solutions already presented, this is an interpolation-ary way in Rails 3 to render a pure Markdown file in a view from a partial without unnecessary indentation using Haml's <code>:markdown</code> filter and the RDiscount gem. The only catch is that your Markdown file is a Haml file, but that shouldn't matter for someone like a copy person.</p> <p>In <strong>Gemfile</strong>:</p> <pre><code>gem 'rdiscount' </code></pre> <p>In <strong>app/views/my_page.html.haml</strong></p> <pre><code>:markdown #{render 'my_partial', language: 'Markdown!'} </code></pre> <p>In <strong>app/views/_my_partial.html.haml</strong></p> <pre><code>My awesome view =============== Look, I can **use** #{language}! </code></pre> <p>If you didn't need the <code>:language</code> variable passed in to the markdown file, you could do away altogether with your Markdown being a Haml file:</p> <p>In <strong>app/views/my_page.html.haml</strong></p> <pre><code>:markdown #{render 'my_partial.md'} </code></pre> <p>In <strong>app/views/_my_partial.md</strong></p> <pre><code>My awesome view =============== Sorry, cannot **use** #{language} here! </code></pre> <p>Don't like those pesky underscores on your Markdown files?</p> <p>In <strong>app/views/my_page.html.haml</strong></p> <pre><code>:markdown #{render file: 'my_markdown.md'} </code></pre> <p>In <strong>app/views/my_markdown.md</strong></p> <pre><code>My awesome view =============== Sorry, cannot **use** #{language} here! </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload