title: Using ERB in Markdown with Redcarpet
body: <p>I'm trying to get Markdown to play nicely with .erb. I'd like to use high_voltage to render markdown pages (or normal .html.erb files with markdown partials) that are parsed with Redcarpet and am struggling to get it to all work together. </p>
  
  <p>At the moment I have an initializer called <code>markdown_template_handler.rb</code> that contains the following code:</p>
  
  <pre class="lang-rb prettyprint-override"><code>class MarkdownTemplateHandler
    def erb
      @erb ||= ActionView::Template.registered_template_handler(:erb)
    end
  
    def call(template)
      compiled_source = erb.call(template)
      markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
  
      "#{markdown.render(compiled_source.source).inspect}.html_safe;"
    end
  end
  
  ActionView::Template.register_template_handler(:md, MarkdownTemplateHandler.new)
  
  </code></pre>
  
  <p>However it is failing at line 7, <code>compiled_source = erb.call(template)</code> with the error code saying "wrong number of arguments (given 1, expected 2)"</p>
  
  <p>I looked at the <a href="https://ruby-doc.org/stdlib-2.6.3/libdoc/erb/rdoc/ERB.html#method-c-new" rel="noreferrer">ERB Ruby documentation</a> but from what I understood, the call method is a derivative of the new method, which only requires 1 argument, the text. However, when I tried to use it just in a quick rails console session, it also required two arguments. </p>
  
  <p>When I remove the requirement to parse erb from the above code, everything works as expected, so I don't think it has anything to do with Redcarpet not working. </p>
  
  <p>I am using Rails v6.0.0.rc1 &amp; Ruby v2.5.3p105</p>
  
  <p>Any help is appreciated.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Further research has led me to finding the <a href="https://edgeapi.rubyonrails.org/classes/ActionView/Template/Handlers/ERB.html#method-i-call" rel="noreferrer">Rails 6.0 ERB ActionView template handler.</a> The call method of this handler does indeed require two arguments, the template and the source. That said, in <a href="https://api.rubyonrails.org/classes/ActionView/Template/Handlers/ERB.html#method-i-call" rel="noreferrer">Rails 5.2.3, the ERB Action View template handler call method</a> only requires one argument, the template. </p>
  
  <p>Could someone please point me in the direction of figuring out what <em>source</em> is in this context? There is no documentation for it that I can find.</p>
  
  <hr>