Rails 3.2 Markdown Template Handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/redcarpet.rb | |
module ActionView | |
module Template::Handlers | |
class Markdown | |
class_attribute :default_format | |
self.default_format = Mime::HTML | |
def call(template) | |
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true) | |
markdown.render(template.source).html_safe.inspect | |
end | |
end | |
end | |
end | |
ActionView::Template.register_template_handler(:md, ActionView::Template::Handlers::Markdown.new) | |
ActionView::Template.register_template_handler(:mdown, ActionView::Template::Handlers::Markdown.new) | |
ActionView::Template.register_template_handler(:markdown, ActionView::Template::Handlers::Markdown.new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@23tux: I think, you should change
"#{@markdown.render(compiled_source).inspect}.html_safe"
to
"#{@markdown.render(compiled_source)}.html_safe"
remove
inspect