我已经安装了gems,redcarpet和pygments.rb,并在我的应用程序助手中创建了一个方法和类,并在我的show.html.erb上调用@content上的方法,但是我收到了一条错误消息。
代码在imgur上 http://imgur.com/a/HAKAc
错误消息显示我在降价方法中用HTMLwithPygments替换Redcarpet :: Render :: HTML
如果您需要查看应用程序的其他位,请询问
请求的错误消息:
MentosError in Posts#show
Showing C:/Sites/mainsite/app/views/posts/show.html.erb where line #23 raised:
Failed to get header.
app/helpers/application_helper.rb:4:in `block_code'
app/helpers/application_helper.rb:18:in `render'
app/helpers/application_helper.rb:18:in `markdown'
app/views/posts/show.html.erb:23:in `_app_views_posts_show_html_erb__448466666_71119812'
Request
Parameters:
{"id"=>"sixth-post"}
下面的应用程序助手:
module ApplicationHelper
class HTMLwithPygments < Redcarpet::Render::HTM
def block_code(code, language)
Pygments.highlight(code, lexer: language)
end
end
def markdown(content)
renderer = HTMLwithPygments.new(hard_wrap: true, filter_html: true)
options = {
autolink: true,
no_intra_emphasis: true,
disable_indented_code_blocks: true,
fenced_code_blocks: true,
lax_html_blocks: true,
strikethrough: true,
superscript: true
}
Redcarpet::Markdown.new(renderer, options).render(content).html_safe
end
end