Note that there are some explanatory texts on larger screens.

plurals
  1. PORendering sections of ERb templates in Markdown with Middleman
    primarykey
    data
    text
    <p>I'm using Middleman (and Ruby, and Rails) for the first time, and I've hit a bit of a roadblock when it comes to rendering individual pages using Redcarpet as my markdown processor, and ERb for layout.</p> <p>I want to use Markdown to style individual blocks of content, but each page will have more than one piece of content, uniquely styled.</p> <p>Rather than using partials, is there a way to instantiate the Redcarpet renderer on multiple areas of the page? So in <code>index.html.erb</code>, there would be something like this:</p> <pre><code>&lt;div class="grid5 container"&gt; &lt;% markdown do %&gt; # Some markdown &lt;% end %&gt; &lt;/div&gt; &lt;section class="grid6"&gt; &lt;% markdown do %&gt; ## More markdown &lt;% end %&gt; &lt;/section&gt; </code></pre> <p>I've tried to build a <a href="http://middlemanapp.com/helpers/#toc_9" rel="nofollow noreferrer">helper</a> <a href="http://dev.af83.com/2012/02/27/howto-extend-the-redcarpet2-markdown-lib.html" rel="nofollow noreferrer">based on</a> <a href="https://stackoverflow.com/questions/2930825/possible-to-embed-markdown-within-erb/2931834#2931834">several</a> <a href="http://asciicasts.com/episodes/272-markdown-with-redcarpet" rel="nofollow noreferrer">tutorials</a>, but I'm just not that good at Rails yet.</p> <p><strong>Edit</strong> My config.rb helper looks like:</p> <pre><code>module MD def markdown(text) Redcarpet.new(text).to_html end end helpers MD </code></pre> <p>per ASCIIcasts, linked above, and my ERb template uses similar code to the above:</p> <pre><code>&lt;span class="g6 pre3"&gt; &lt;% markdown do %&gt; ...etc... &lt;% end %&gt; </code></pre> <p>but I'm getting an error when I load the page: <code>ArgumentError at /about wrong number of arguments (0 for 1)</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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